reactjs / reactjs/react-docgen
Doesn't find HOCs that just wrap & re-export component
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
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.
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.
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.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100