-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
createAnimatedComponent should support stateless functional components [React Hooks] #22066
Comments
I don't think this requires a new issue, you can comment on the original issue itself. |
@hramos this is still an issue in 0.59.1, can this be reopened? |
@MrLoh It looks as though createAnimatedComponent requires a ref (which functional components don't provide). You can get around the issue by using React.forwardRef with your function component. |
yeah, that was an obvious solution. Should have thought of that myself |
@MrLoh Can you please explain how to did this, using forwardRef ? |
const MyFunctionalComponent = React.forwardRef((props, ref) => <View ref={ref}> ... ); then you can do createAnimatedComponent(MyFunctionalComponent); |
Actually. The component which is stateless is inside library. Can I pass ref to that without forking the library code? |
Does the library component accept a |
Okay, Thanks |
I just tried this w/ a forwardRef and received the same error, and looking at the code of how forwardRef works, it is unclear it would pass this check. Does the forwardRef trick still work for people running on 16.8? |
For Discussion
I am starting to play with hooks in react native following guide posted by hramos
#21967 (comment)
Off the bat I got an error
This was as a result of me converting my simplest components (that don't rely on anything related to hooks) to functions and I assume will be an issue further down the road since vision of react for the future is to use less classes and more function components.
The text was updated successfully, but these errors were encountered: