{"id":19356,"library":"babel-react-components","title":"Babel React Components","description":"Utility library for identifying and working with React components in Babel AST transformations. Version 1.1.0 provides helper functions like isReactComponentClass to detect React component classes in Babel plugin development. Limited release cadence; focuses on providing reliable helpers for Babel plugin authors. Differentiates by specifically targeting React class components detection with accurate Babel path checking.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/babel-utils/babel-react-components","tags":["javascript"],"install":[{"cmd":"npm install babel-react-components","lang":"bash","label":"npm"},{"cmd":"yarn add babel-react-components","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-react-components","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM only; CJS require not supported.","wrong":"const isReactComponentClass = require('babel-react-components').isReactComponentClass","symbol":"isReactComponentClass","correct":"import { isReactComponentClass } from 'babel-react-components'"},{"note":"If using TypeScript, prefer type import to avoid runtime bundling.","wrong":"import { isReactComponentClass } from 'babel-react-components'","symbol":"isReactComponentClass (type import)","correct":"import type { isReactComponentClass } from 'babel-react-components'"},{"note":"No default export; must use namespace or named imports.","wrong":"import BabelReactComponents from 'babel-react-components'","symbol":"default import","correct":"import * as BabelReactComponents from 'babel-react-components'"}],"quickstart":{"code":"import { isReactComponentClass } from 'babel-react-components';\n\nexport default function babelPlugin() {\n  return {\n    visitor: {\n      ClassDeclaration(path) {\n        if (isReactComponentClass(path)) {\n          console.log('Found React component:', path.node.id.name);\n        }\n      }\n    }\n  };\n}","lang":"javascript","description":"Shows how to use isReactComponentClass in a Babel plugin visitor to detect React class components."},"warnings":[{"fix":"Ensure you pass a Babel NodePath object, not a node or code string.","message":"The function only works on Babel AST paths, not on regular JavaScript objects or source code strings.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use additional checks for ArrowFunctionExpression, FunctionDeclaration, CallExpression with member expression (React.forwardRef), etc.","message":"May not detect functional components or components created with React.forwardRef or React.memo.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use named import: import { isReactComponentClass } from 'babel-react-components'","cause":"Importing incorrectly, likely using default import or CJS require.","error":"TypeError: isReactComponentClass is not a function"},{"fix":"Run npm install babel-react-components or add to package.json dependencies.","cause":"Package not installed or incorrectly referenced in tsconfig.json paths.","error":"Cannot find module 'babel-react-components'"},{"fix":"Change to regular import: import { isReactComponentClass } from 'babel-react-components'","cause":"Using type-only import for a runtime function.","error":"TypeScript error: 'isReactComponentClass' cannot be used as a value because it was imported using 'import type'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}