Troubleshooting Guide
Find solutions to common problems when using React Icons.Installation Issues
Package Installation Fails
npm install fails with permission errors
npm install fails with permission errors
Yarn install fails with network errors
Yarn install fails with network errors
Problem: Network timeouts or connection errorsSolution:
Module not found after installation
Module not found after installation
Problem:
Cannot find module 'react-icons'Solution:- Verify installation:
- If missing, reinstall:
- Check import path:
Import & Build Issues
Icons Not Rendering
Icons show as empty elements
Icons show as empty elements
Problem: Icons don’t appear but no errors in consoleDiagnosis:Solutions:
- Check import syntax:
- Verify icon name is correct:
- Ensure React is imported:
SVG not visible (size is 0)
SVG not visible (size is 0)
Problem: Icon renders but has no sizeSolution:Icons default to
1em - ensure parent has font-size set:Bundle Size Issues
Bundle size is too large
Bundle size is too large
Problem: Bundle includes many unused iconsDiagnosis:Analyze your bundle:Common causes & fixes:Vite - works by defaultCreate React App - works by default in production buildsSee Performance Optimization for more tips.
- Importing entire library:
- Dynamic imports with wildcard:
- Bundler not tree-shaking:
webpack.config.js
Tree-shaking not working
Tree-shaking not working
Problem: All icons from a pack are includedCheck:
- Using production build:
- Module format:
package.json
- Bundler configuration:
- Import from correct path:
TypeScript Issues
Type errors with icon imports
Type errors with icon imports
Problem: TypeScript can’t find typesSolution:React Icons v3+ includes native TypeScript support.Requires TypeScript 4.0+
- Remove conflicting types:
- Update TypeScript:
- Check tsconfig.json:
IconType not working
IconType not working
Problem: Make sure to destructure and capitalize:
IconType type errorsSolution:Type 'Element' is not assignable to type 'ReactNode'
Type 'Element' is not assignable to type 'ReactNode'
Problem: Type mismatch in strict modeSolution:
Framework-Specific Issues
Next.js
Icons not rendering in Next.js App Router
Icons not rendering in Next.js App Router
Problem: Icons don’t show in Server ComponentsSolution:Icons work in Server Components, but IconContext needs Client Component:
app/icon-provider.jsx
app/layout.jsx
Build fails with 'Cannot find module'
Build fails with 'Cannot find module'
Problem: Next.js build fails importing iconsSolution:Requires Next.js 12+
- Check Next.js version:
- Verify import paths:
Create React App
Icons not updating after build
Icons not updating after build
Problem: Changes to icons don’t reflect in buildSolution:
Vite
Import errors with Vite
Import errors with Vite
Problem:
Failed to resolve importSolution:Vite works with React Icons by default. If you see errors:vite.config.js
Styling Issues
Icons misaligned with text
Icons misaligned with text
Problem: Icons don’t align vertically with textSolution:React Icons v3+ removed automatic alignment. Add it back:See Migration v2 to v3 for details.
Icons don't respond to color prop
Icons don't respond to color prop
Problem: Color prop doesn’t workCheck:Solution:
- Not using multiColor icons:
- CSS specificity:
Tailwind classes not working
Tailwind classes not working
Problem: Tailwind CSS classes have no effectSolution:Note: Tailwind’s size utilities override the icon’s default
1em size.Context API Issues
IconContext not applying styles
IconContext not applying styles
Problem: Context values don’t affect iconsCheck:
- Icons are inside Provider:
- Props override context:
Nested contexts not working correctly
Nested contexts not working correctly
Problem: Inner context doesn’t override outerExpected behavior:Inner contexts merge with outer contexts, with inner values taking precedence.
Error Messages
Warning: React does not recognize prop
Warning: React does not recognize prop
Problem:
Warning: React does not recognize the 'size' prop on a DOM elementCause: Passing icon props to wrong elementSolution:Element type is invalid
Element type is invalid
Problem:
Error: Element type is invalid: expected a string or a class/functionCause: Import failed or component not capitalizedSolution:Getting More Help
FAQ
Check frequently asked questions
GitHub Issues
Search existing issues or report a bug
GitHub Discussions
Ask the community for help
Stack Overflow
Search or ask questions