-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Memo + ForwardRef = false positive? #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
forwardRef callbacks aren’t components and don’t take props or propTypes - if you have a forwardRef, why isn't it using the ref argument? |
Whoops, you're right, forgot the 2nd param "Ref" for this example. Fixed. I realized that forwardRef'd components don't have propTypes, what I'm saying is Eslint complains if I don't validate props using propTypes when I have a memoized forwardRef. If fowardRef doesn't have propTypes then a memoized forwardRef shouldnt either, yet eslint want's me to add propTypes to it. |
If it only happens with the combination - ie, with memo and forwardRef, but not just with forwardRef - then it’s definitely a bug. |
That's what i thought. |
Having multiple wrapper was not supported, it should be fixed in Also you must add the const myComponent = memo(forwardRef(({ myProp }, ref) => {
// ...
}))
myComponent.propTypes = { myProp: PropTypes.number.isRequired }
default export myComponent; |
Thanks for the fix! |
Eslint complains about myProp being missing in prop validation
when a forwardRef'd component is memoized.
If I add myProp to prop validation.
Then eslint stops complaining, but now the site wont render:
Is there someway to use memo and forwardRef that eslint doesn't complain about?
The text was updated successfully, but these errors were encountered: