Hot Reloading fails when setting properties on class
- Dominant language
- JavaScript
- Stars
- 797
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
Hey! Thanks a ton for the package here! I can imagine the reports can get overwhelming, especially with the rapid changes facebook has made to the package and syntax since inception. Here is another thing I have been running into.
This is a:
- [x] Bug Report
- [ ] Feature Request
- [ ] Question
- [ ] Other
Which concerns:
- [x] flow-runtime
- [x] babel-plugin-flow-runtime
- [ ] flow-runtime-validators
- [ ] flow-runtime-mobx
- [ ] flow-config-parser
- [ ] The documentation website
---
### What is the current behavior?
When setting up types on props or state using the methods recommended by the library author, it will cause errors and won't allow hot reloading to occur. Removing flow-runtime fixes the problem and writing the types in another way can fix the problem but also are not always the ideal way of implementing.
```js
// this appears to allow hot reloading
class LoginViewContainer extends Component<*, LoginViewProps, LoginViewState> {
...
}
```
```js
// this will not work at all
class LoginViewContainer extends Component {
props: LoginViewProps
state = {
...
}
}
```
and the error:
```
// you can ignore the asyncComponent part - that is just the wrapper component that happens to
// be catching the error itself that is occurring.
asyncComponent.js:186 TypeError: Cannot redefine property: props
at Function.defineProperty ()
at defineProxyProperty (http://localhost:1212/dist/bundle.js:38972:12)
at http://localhost:1212/dist/bundle.js:39056:9
at Array.forEach (native)
at Object.update (http://localhost:1212/dist/bundle.js:39049:18)
at Object.update (http://localhost:1212/dist/bundle.js:38826:45)
at Object.register (http://localhost:1212/dist/bundle.js:38390:23)
at http://localhost:1212/dist/6.bundle.js:428:24
at Object../app/screens/Login/Login.js (http://localhost:1212/dist/6.bundle
```
---
### What is the expected behaviour?
My guess it that the automatically generated props are not properly handling a hot reload and are instead trying to redefine the properties that are already defined. From the error it would appear a simple check could resolve this, although I am not too familiar with the inner-workings of the react-hot-loader package & friends.
---
### Which package versions are you using?
```
"flow-runtime": "^0.13.0",
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.