Doesn't find HOCs that just wrap & re-export component
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, react
- Domain
- documentation
Research direction
Start with the hello-button.js and button.js examples, then trace the findAllComponentDefinitions resolver to see why a component imported and wrapped by connect is missed. Confirm the change by checking that HelloButton is recognized as a component while Button remains correctly parsed.
Written by the indexing model from the issue text.
Description
Some HOCs aren't correctly parsed when they're just calling a function on an imported component. For example, exporting a HelloButton component that just exports an imported Button component wrapped in redux connect:
hello-button.js:
// @flow
import { connect } from 'react-redux';
import { sayHello } from '../actions/hello';
import Button from '../components/Button';
const mapStateToProps = () => ({
label: 'Say something',
});
const mapDispatchToProps = dispatch => ({
handleClick: () => {
dispatch(sayHello('Hi!!!'));
},
});
// HelloButton
export default connect(mapStateToProps, mapDispatchToProps)(Button);
button.js:
// @flow
import React from 'react';
import './index.css';
type Props = {
label: string,
handleClick: Function
};
const Button = ({ label, handleClick }: Props) =>
<button styleName='button' onClick={handleClick}>{label}</button>
;
export default Button;
Button is properly parsed, but HelloButton is not considered a component, even when using the findAllComponentDefinitions resolver.
- 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
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dennys-bd/agent-hive#184 ·
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vicharanashala/fln#563 ·