Skip to content
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

v6: prefer components in normalizeComponent #1609

Merged
merged 2 commits into from Nov 20, 2019
Merged

v6: prefer components in normalizeComponent #1609

merged 2 commits into from Nov 20, 2019

Conversation

henryqdineen
Copy link

@henryqdineen henryqdineen commented Oct 21, 2019

We have been using v6.10.0 and one of our cell components was changed to use React.memo and the table unexpectedly stopped working. It looks like other have users reported issues with normalizeComponent in various versions and some fixes have been made.

Unfortunately some users have code that assumes the "components" are just a element factory and not a true React component. When these React components are defined inline this can cause unmounts when the parent component is re-rendered. This branch will not fix that issue but I think instead users should avoid creating inline components and just use React context if you absolutely need to provide anything to these components.

The fix for us was to use isValidElementType from react-is for component detection and allow us to use React.memo, React.forwardRef, etc. We think this solution is cleaner and providers a more predictable API. We weren't comfortable with the existing String(component).includes('.createElement') detection and have a lot of examples where that fails.

I understand that this probably won't be merged but it could be helpful for others that might fork this lib. Thanks!

Other changes

  • updated prop-types peer dep to ^15.7.0 because that is when elementType was introduced
  • add react-is peer dep
  • update column "renderer" prop types to more closely reflect the new logic in normalizeComponent

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ec3fb68:

Sandbox Source
zealous-gauss-409tz Configuration

@leeyeh
Copy link

leeyeh commented Oct 25, 2019

Just running into the same issue with React.memo and React.forwardRefwrapped component.

Hope this PR got landed soon.

@tannerlinsley
Copy link
Collaborator

Make react-is a direct dependency and you've got yourself a deal.

@henryqdineen
Copy link
Author

Done! Thanks

@tannerlinsley tannerlinsley merged commit f2e62a1 into TanStack:v6 Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants