No suitable component definition found for higher-order component
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, react
- Domain
- documentation, tooling
Research direction
Start with the src/components/Test.jsx higher-order-component reproduction and run the shown react-docgen CLI command. Trace the parse path named in the error, then verify that the wrapped component is recognized and produces metadata like the direct-function example.
Written by the indexing model from the issue text.
Description
react-docgen can't find a component definition when the component is defined as a higher-order component:
import React from 'react';
const wrap = (CustomElement) => (props) =>
<CustomElement { ...props } >{ props.children }</CustomElement>
const Test = wrap('custom-element');
export default Test;
> node_modules/.bin/react-docgen src/components/Test.jsx
Error with path "src/components/Test.jsx": Error: No suitable component definition found.
Error: No suitable component definition found.
at parse (/private/tmp/test/bindings/react/node_modules/react-docgen/dist/parse.js:84:9)
at Object.defaultParse [as parse] (/private/tmp/test/bindings/react/node_modules/react-docgen/dist/main.js:66:30)
at parse (/private/tmp/test/bindings/react/node_modules/react-docgen/bin/react-docgen.js:103:17)
at /private/tmp/test/bindings/react/node_modules/react-docgen/bin/react-docgen.js:204:30
at FSReqWrap.oncomplete (fs.js:153:5)
If I apply the function myself, react-docgen works as expected:
const Test = (props) =>
<custom-element { ...props } >{ props.children }</custom-element>
> node_modules/.bin/react-docgen src/components/Test.jsx
{"description":"","displayName":"Test","methods":[]}
Tested with react-docgen@2.21.0.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 3h 28m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reactjs/react-docgen
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
reactjs/react-docgen#1102 ·
-
Typescript Status Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
reactjs/react-docgen#1005 · 4 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
reactjs/react-docgen#997 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
reactjs/react-docgen#994 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
reactjs/react-docgen#982 · 2 comments ·
All issues in reactjs/react-docgen
Similar issues
-
S: triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
fix(errors): EHOSTUNREACH from a happy-eyeballs connect is reported as a resolver error (STAMP-80) Open
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
snapshot-labs/stamp#666 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
GauravKarakoti/SecureFlow#1070 · 1 comment ·
-
comp/desktop P3 type/bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NousResearch/hermes-agent#118866 ·