Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with React 16.3 forwardRef #82

Open
haggholm opened this issue Aug 4, 2018 · 6 comments
Open

Does not work with React 16.3 forwardRef #82

haggholm opened this issue Aug 4, 2018 · 6 comments

Comments

@haggholm
Copy link

haggholm commented Aug 4, 2018

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 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)

{
  $$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.

@JulianKingman
Copy link

JulianKingman commented Aug 20, 2018

@haggholm any progress on this issue?
Edit: I'm also getting this issue with ReactContext.Provider

@haggholm
Copy link
Author

Unfortunately I haven’t had time to return to it yet.

@alex-mcleod
Copy link

alex-mcleod commented Sep 29, 2018

I have also been getting this issue when using a HOC that includes React.forwardRef. This error only appears when the HOC is applied as a class decorator.

@syq7970
Copy link

syq7970 commented Sep 30, 2018

+1 same issue.

@alex-mcleod
Copy link

I've added some updated information and a short-term fix to facebook/metro#272

@lukasikora
Copy link

Similar issue with debugging results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants