-
Notifications
You must be signed in to change notification settings - Fork 11
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
Memoize cloned element in tooltip #167
Conversation
src/components/Tooltip/Tooltip.tsx
Outdated
...children.props, | ||
}); | ||
return cloneElement(children, props); | ||
}, [ref, children, isValidElement(children) && children.props]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&&
here is unexpected, it implies breaking rules-of-hooks, can it get a comment to explain it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it breaking the rules of hooks? I can declare it before but it doesn't change anything to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this project doesn't use https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks which has rules-of-hooks. https://www.reddit.com/r/reactjs/comments/13oy1r5/is_eslint_exhaustive_deps_a_bad_rule_sometimes/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. I added a comment. It's needed to be able to infer the type of children to have access to the props
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more questioning why &&
instead of ,
- a comment or maybe breaking it out into a sanely named variable could go a long way to clarifying it
No description provided.