react-icon-base is a foundational React component designed to provide a consistent base for rendering SVG icons, primarily intended for internal use by icon libraries, such as older iterations of `react-icons`. It encapsulates an SVG element, allowing for a custom `viewBox` and direct SVG children, while also facilitating consistent styling, sizing, and color propagation via React's now-legacy context API (`childContextTypes`). The package's current stable version is 2.1.2, with its last publish occurring over seven years ago. Its deep reliance on `React.Component` and the deprecated `childContextTypes` API renders it largely incompatible with modern React versions (16.3+ for new context API, 18+ for complete removal of legacy context) without substantial compatibility layers or downgrading the React version. It is no longer actively maintained and should be considered abandoned for new project development.
npm install react-icon-baseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a custom SVG icon using `IconBase` and how to configure its default props globally using the legacy `childContextTypes` API. The `FaHeart` component wraps the SVG path in `IconBase`, while `IconWrapper` provides context.
For new projects or existing projects upgrading to React 16.3+, it is strongly recommended to use a modern icon library (e.g., `react-icons` v3+, which no longer uses this base package) that leverages the new Context API or passes props directly. If forced to use, consider a React compatibility layer like `@legacy-react/context-api` (if available and maintained) or pin React to a version below 16.3.
Migrate to a currently maintained icon library or component solution. Avoid using this package in any new development.
Ensure your build tool (Webpack, Rollup, Parcel, Vite) is configured to correctly handle CommonJS modules. If using Node.js with `"type": "module"` in `package.json`, you might need dynamic `import()` or specific loader configurations.
This package is not compatible with React 18+. To fix, downgrade your React version to <16.3, or, preferably, replace `react-icon-base` with a modern, actively maintained icon solution.
Ensure you are using `import IconBase from 'react-icon-base';` as it is a default export. Verify your build system correctly transpiles/resolves CommonJS modules if you are in an ES Module environment.