You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that if I use memo or forwardRef (or both) and remove React import from file - prop types validation stops working. Here are examples:
working fine (import React exists, "'title' is missing in props validation" error showing):
constReact=require('react');constmyComponent=React.memo(({ title })=>{return(<divtitle={title}>test</div>);});myComponent.propTypes={}module.exports=myComponent;
not working fine (I removed React import):
const{memo}=require('react');constmyComponent=memo(({ title })=>{return(<divtitle={title}>test</div>);});myComponent.propTypes={}module.exports=myComponent;
In theory each file that uses react components should import React object, but user may configure build system to import that object automatically on build stage to avoid typing boring import statements in each file (I did that in my project, React automatically resolves via webpack.ProvidePlugin, that's why I face this bug).
I think eslint should handle that situations properly, because "react/react-in-jsx-scope" rule works fine if React resolved via webpack.providePlugin (and "env": {"React": true} is set in eslint config).
The text was updated successfully, but these errors were encountered:
This issue relates to this one: #2349
The problem is that if I use
memo
orforwardRef
(or both) and remove React import from file - prop types validation stops working. Here are examples:working fine (import React exists, "'title' is missing in props validation" error showing):
not working fine (I removed React import):
In theory each file that uses react components should import React object, but user may configure build system to import that object automatically on build stage to avoid typing boring import statements in each file (I did that in my project, React automatically resolves via webpack.ProvidePlugin, that's why I face this bug).
I think eslint should handle that situations properly, because "react/react-in-jsx-scope" rule works fine if React resolved via webpack.providePlugin (and "env": {"React": true} is set in eslint config).
The text was updated successfully, but these errors were encountered: