gaearon / gaearon/react-hot-loader

hot() does not forward the ref props to its children

Open
#964 7 comments 3 reactions 1 assignee Claimed by @theKashey View on GitHub
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 (

Hello {this.props.name}
)
}
};

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

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.