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

Check that container exists before calling removeChildren #286

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

kyle-villeneuve
Copy link
Contributor

@kyle-villeneuve kyle-villeneuve commented Oct 8, 2022

This addresses an error I've repeatedly encountered in production (may have something to do with React.Suspense and/or React.lazy imports. Just ensures that the container exists before attempting to remove its contents.

TypeError: Cannot read properties of null (reading 'removeChildren')
	at removeChildren (../../src/ReactPixiFiber.js:122:12)
	at xb (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:131:296)
	at Jf (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:174:304)
	at ih (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:171:235)
	at vc (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:36:324)
	at Pc (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:169:278)
	at Zg (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:160:369)

This addresses an error I've repeatedly encountered in production (may have something to do with `React.Suspense` and/or `React.lazy` imports. Just ensures that the container exists before attempting to remove it.

```
TypeError: Cannot read properties of null (reading 'removeChildren')
	at removeChildren (../../src/ReactPixiFiber.js:122:12)
	at xb (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:131:296)
	at Jf (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:174:304)
	at ih (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:171:235)
	at vc (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:36:324)
	at Pc (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:169:278)
	at Zg (../../node_modules/react-reconciler/cjs/react-reconciler.production.min.js:160:369)
```
@codesandbox
Copy link

codesandbox bot commented Oct 8, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 8, 2022

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 aa060d6:

Sandbox Source
React Configuration
React Typescript Configuration
examples Configuration

Copy link
Owner

@michalochman michalochman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kyle-villeneuve! Seems like an obvious fix. I will merge and release it if you can update code formatting.

src/ReactPixiFiber.js Outdated Show resolved Hide resolved
Co-authored-by: Michał Ochman <[email protected]>
@kyle-villeneuve
Copy link
Contributor Author

Ok, I've committed your suggestion, thanks. @michalochman

@michalochman michalochman merged commit f64aa82 into michalochman:master Oct 11, 2022
@michalochman
Copy link
Owner

michalochman commented Oct 11, 2022

@kyle-villeneuve thanks! The fix is now included in [email protected].

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.

2 participants