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

State initialization disparity between shallow renderer and ReactDOM #11964

Closed
jwbay opened this issue Jan 4, 2018 · 1 comment
Closed

State initialization disparity between shallow renderer and ReactDOM #11964

jwbay opened this issue Jan 4, 2018 · 1 comment

Comments

@jwbay
Copy link
Contributor

jwbay commented Jan 4, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
The shallow renderer defaults a class component's state to empty object if it's not set. "Real" renderers don't seem to do this, so a component can render successfully in the shallow renderer, but fail at runtime in the browser with a null reference error.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Here is ReactDOM's behavior (crashes reading an uninitialized state value): https://codesandbox.io/s/4jv82zmp0
Here is the shallow renderer behavior (component able to render): https://codesandbox.io/s/pp733nrxzq

What is the expected behavior?
They initialize state in the same way.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16. This wasn't an issue in React 15.

@gaearon
Copy link
Collaborator

gaearon commented Jan 4, 2018

This is a bug in the shallow renderer. Want to send a fix?

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

No branches or pull requests

2 participants