gaearon / gaearon/react-hot-loader

this.state becoming null in mobx-react observer-wrapped component

Open
#1,235 9 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
12.2k
Forks
775
PR merge metrics
No merged PRs in 30d

Description

### Description

What you are reporting:

Bug (or my own misunderstanding). When I edit a stateful class component that is wrapped in an `observer()` from mobx-react, `this.state` becomes null at some point, during a render attempt.

### Expected behavior

What you think should happen: `this.state` should never change to null.

### Actual behavior

What actually happens: `this.state` changes to null.

### Environment

React Hot Loader version:

Run these commands in the project folder and fill in their results:

1. `node -v`: 10.15.1
2. `npm -v`: 6.8.0
3. `yarn -v`: 1.13.0

Then, specify:

1. Operating system: MacOS 10.14.4
2. Browser and version: Chrome 73.0.3683.103

### Reproducible Demo

I just did create-react-app, eject, and added hot-loader + mobx-react, before reproing the bug:

https://github.com/yang/hot-cra-observer-repro

Video of reproing the error: you must first click to toggle off the Widget, then trigger a hot-reload in the Widget, and then click to toggle the Widget back in.

https://youtu.be/47AaO8IEwqo

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.