Skip to content

Conversation

@ZauberNerd
Copy link
Contributor

When searching for a MemberExpresion (i.e. "propTypes") that is defined
on an object (ArrowFunctionExpression, FunctionExpression,
FunctionDeclaration or VariableDeclaration), take the local Identifier
into account to find the member of the correct object.

Before:
When using multiple components per file, it would for every component
take the propTypes of the last component encountered.

function Component1() { return (<i />); }
Component1.propTypes = { a: React.PropTypes.string };
function Component2() { return (<b />); }
Component2.propTypes = { b: React.PropTypes.number };

After:
Now it checks whether the property of the MemberExpression actually
belongs to the correct object.

When searching for a MemberExpresion (i.e. "propTypes") that is defined
on an object (ArrowFunctionExpression, FunctionExpression,
FunctionDeclaration or VariableDeclaration), take the local Identifier
into account to find the member of the correct object.

Before:
When using multiple components per file, it would for every component
take the propTypes of the last component encountered.
```javascript
function Component1() { return (<i />); }
Component1.propTypes = { a: React.PropTypes.string };
function Component2() { return (<b />); }
Component2.propTypes = { b: React.PropTypes.number };
```

After:
Now it checks whether the property of the MemberExpression actually
belongs to the correct object.
@ZauberNerd ZauberNerd force-pushed the improve-proptypes-handler branch from 471e646 to 00ec55a Compare August 14, 2016 10:14
@fkling
Copy link
Member

fkling commented Aug 18, 2016

Can't believe how this wasn't noticed earlier. Thank you!!

@fkling fkling merged commit 4f6c5ee into reactjs:master Aug 18, 2016
@ZauberNerd ZauberNerd deleted the improve-proptypes-handler branch August 19, 2016 13:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants