Does not work with React 16.3 forwardRef
- Dominant language
- JavaScript
- Stars
- 453
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Please excuse a somewhat vague report as I’m just investigating a rather involved build system.
Our codebase has (a) a custom component base class, which is generally discouraged; and (b) HOCs that use the new `forwardRef()` functionality. This lead to a very strange breakage when I tried to migrate some components that currently use our internal `BaseComponent` to instead extend `React.Component` (or `PureComponent`) directly: our React Native app crashed in [react-proxy’s update() function](https://github.com/gaearon/react-proxy/blob/v1.1.8/src/createClassProxy.js#L103) with the error `'Expected a constructor.'`. It appears that when extending the React classes, the component ends up being not a class, but instead an object with the shape (per Chrome debugger)
```javascript
{
$$typeof: Symbol(react.forward_ref),
render: forwardFn(props, ref) { ... }
}
```
It’s not clear to me why this does *not* happen with our custom base class: I suppose `forwardRef()` treats it differently, being a full-blown ES6 class as opposed to what React provides. It’s also not clear to me exactly where I should be filing this bug: `react-proxy`, `react-transform-hmr`, `metro`, …? Any thoughts welcomed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.