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
Module not found after installation
Module not found after installation
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
- Check import syntax:
- Verify icon name is correct:
- Ensure React is imported:
SVG not visible (size is 0)
SVG not visible (size is 0)
1em - ensure parent has font-size set:Bundle Size Issues
Bundle size is too large
Bundle size is too large
- Importing entire library:
- Dynamic imports with wildcard:
- Bundler not tree-shaking:
Tree-shaking not working
Tree-shaking not working
- Using production build:
- Module format:
- Bundler configuration:
- Import from correct path:
TypeScript Issues
Type errors with icon imports
Type errors with icon imports
- Remove conflicting types:
- Update TypeScript:
- Check tsconfig.json:
IconType not working
IconType not working
IconType type errorsSolution:Type 'Element' is not assignable to type 'ReactNode'
Type 'Element' is not assignable to type 'ReactNode'
Framework-Specific Issues
Next.js
Icons not rendering in Next.js App Router
Icons not rendering in Next.js App Router
Build fails with 'Cannot find module'
Build fails with 'Cannot find module'
- Check Next.js version:
- Verify import paths:
Create React App
Icons not updating after build
Icons not updating after build
Vite
Import errors with Vite
Import errors with Vite
Failed to resolve importSolution:Vite works with React Icons by default. If you see errors:Styling Issues
Icons misaligned with text
Icons misaligned with text
Icons don't respond to color prop
Icons don't respond to color prop
- Not using multiColor icons:
- CSS specificity:
Tailwind classes not working
Tailwind classes not working
1em size.Context API Issues
IconContext not applying styles
IconContext not applying styles
- Icons are inside Provider:
- Props override context:
Nested contexts not working correctly
Nested contexts not working correctly
Error Messages
Warning: React does not recognize prop
Warning: React does not recognize prop
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
Error: Element type is invalid: expected a string or a class/functionCause: Import failed or component not capitalizedSolution: