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

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

Open
av-k opened this issue Dec 13, 2024 · 6 comments · Fixed by #740
Open

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

av-k opened this issue Dec 13, 2024 · 6 comments · Fixed by #740
Assignees
Labels

Comments

@av-k
Copy link

av-k commented Dec 13, 2024

During running app on React.js v.19.0.0 in development mode and using React.StrictMode I get the next error:

TypeError: Cannot read properties of null (reading 'getState')

it happens during unmounting and mounting a component that uses:

import {Table, Column} from 'fixed-data-table-2';

Expected Behavior

There are no errors.

Current Behavior

There is an syntax error.

Possible Solution

The broken place is here:

...this.reduxStore.getState(),

The cause of this issue is here:
this.reduxStore = null;

Steps to Reproduce

  1. Run app with React v.19.0.0 in development mode with wrapper:

<React.StrictMode>
{...}
</React.StrictMode>

  1. Use any custom component which uses Table element from 'fixed-data-table-2'.

Your Environment

  • Version used: 2.0.17
  • Browser Name and version: Chrome Version 131.0.6778.85 (Official Build) (64-bit)
  • Operating System and version (desktop or mobile): Fedora 6.11.9-100.fc39.x86_64
@pradeepnschrodinger
Copy link
Collaborator

Thanks for reporting the issue.
This looks very similar to the NPE we saw in #657 in the past.

I'll put up a PR soon.

@pradeepnschrodinger
Copy link
Collaborator

Fixed with v2.0.19 via #740.

@av-k , I'm marking the issue as completed but feel free to comment if you face issues.

@pradeepnschrodinger pradeepnschrodinger self-assigned this Dec 16, 2024
@zuyetawarmatik
Copy link

zuyetawarmatik commented Jan 4, 2025

The issue happens on our project, using latest v2.0.19, React 18.3

In render(), it accesses getApi() while componentWillUnmount() has already run, causing this.reduxStore to be null, and crash the page due to null reference.

Maybe can it be fixed in a way that's more defensive when accessing reduxStore?

...this.reduxStore?.getState(),

@pradeepnschrodinger
Copy link
Collaborator

@zuyetawarmatik, thanks for reporting. That's weird, I'll reopen this issue and take another look.
Are you using strict mode in your project?

@zuyetawarmatik
Copy link

zuyetawarmatik commented Jan 6, 2025

@pradeepnschrodinger We use React 18.3 without wrapping in StrictMode. It's also weird to me that render() is still called even componentWillUnmount() has already been called to cleanup, but it has happened.

Screenshot 2025-01-06 at 3 06 25 PM

"fixed-data-table-2": "^2.0.19",
"react": "^18.3.1",
"react-dom": "^18.3.1",

@pradeepnschrodinger
Copy link
Collaborator

@zuyetawarmatik , unfortunately I'm not able to reproduce this 😔.

In render(), it accesses getApi() while componentWillUnmount() has already run

You mentioned not using StrictMode, but the table still seems to be unmounted.
Is the app unmounting the table component at some point? When exactly is the TypeError being raised?

Any chance you can share a link to the project code? Or maybe get a small sandbox running so I can take a look at how FDT is used?
You can use this simple template as an example.

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 a pull request may close this issue.

3 participants