gaearon / gaearon/react-hot-loader
hot() does not forward the ref props to its children
- Dominant language
- JavaScript
- Stars
- 12.2k
- Forks
- 775
- PR merge metrics
- No merged PRs in 30d
Description
### Description
When using a `ref` prop in a hot-enabled Root component with `ReactDOM.render`, the parameter passed to the `ref` callback should be the real component, not the proxy component (ref forwarding ?).
Example code:
```es6
var onButtonClick = function() {
window.helloComponent.alertMessage();
}
class Hello extends React.Component {
alertMessage() {
alert(this.props.name);
}
render() {
return (
}
};
ReactDOM.render(
{window.helloComponent = element}}/>,
document.getElementById('container')
);
```
### Expected behavior
When calling `onButtonClick`, `Hello.alertMessage()` should be called
### Actual behavior
What actually happens:
```
Uncaught TypeError: window.helloComponent.alertMessage() is not a function
```
This happens because `window.helloComponent` is a `ProxyComponent` object, not the expected instance of the `Hello` class
### Environment
React Hot Loader version: 4.1.2
Contributor guide
Assessment
This issue has not been assessed yet.