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

Fix StrictMode errors in FixedDataTableContainer #740

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

pradeepnschrodinger
Copy link
Collaborator

Description

When StrictMode is enabled, and FDT is run under React v19, we run into NPEs in the top-level FixedDataTableContainer component, causing the table to not function correctly.

In StrictMode runs the constructor and lifecycle methods of FixedDataTableContainer a second time.
The order I observed was as follows:

constructor
constructor
getDerivedStateFromProps
getDerivedStateFromProps
componentDidMount
componentWillUnmount
componentDidMount
getDerivedStateFromProps
getDerivedStateFromProps

So when running in StrictMode, the handlers/redux store gets initialized in the constructor, and then immediately gets destroyed in componentWillUnmount, leading the table to be in a destroyed state.

I'm fixing this by moving the initialization logic to both the constructor and componentDidMount, following what we did in #657 in the past.

Motivation and Context

Fixes #738.

How Has This Been Tested?

Tested with local examples running React v19.
Tested with a Vite client app running React v19.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

@karry08
Copy link
Collaborator

karry08 commented Dec 16, 2024

lgtm

@pradeepnschrodinger pradeepnschrodinger merged commit 3924dff into master Dec 16, 2024
10 checks passed
@pradeepnschrodinger pradeepnschrodinger deleted the FixReact19StrictModeNPE branch December 16, 2024 20:46
@pradeepnschrodinger
Copy link
Collaborator Author

Released with v2.0.19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of null (reading 'getState') in React v.19.0.0
2 participants