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

Hooks and function components? #60

Open
evelant opened this issue Jul 22, 2020 · 2 comments
Open

Hooks and function components? #60

evelant opened this issue Jul 22, 2020 · 2 comments

Comments

@evelant
Copy link

evelant commented Jul 22, 2020

fable-react supports function components but it seems they can't be used in fable-react-native. Am I missing something here (likely, I'm new to f#)? My react-native app crashes if I try to use Fable.React.FunctionComponent.Of(...)

 ERROR    TypeError: module.hot.addStatusHandler is not a function. (In 'module.hot.addStatusHandler(function (status) {
        if (status === "apply") (function () {
          cache.clear();
        })();
      })', 'module.hot.addStatusHandler' is undefined)
[Wed Jul 22 2020 11:36:26.377]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Wed Jul 22 2020 11:36:26.377]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Wed Jul 22 2020 11:36:26.377]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling unmountApplicationComponentAtRootTag)
[Wed Jul 22 2020 11:36:26.378]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
@alfonsogarciacaro
Copy link
Member

Sorry for the late reply, I don't use react-native often but I guess it should be possible to use the function components. From the error message I guess the error comes from the code we added to interact with Webpack's HMR. Seems like react-native also exposes module.hot functionality with a different API. Wrapping this in a try ... catch should work I guess: https://github.com/fable-compiler/fable-react/blob/815cff886cfe12bca31efd1193f2bf496b77c231/src/Fable.React.FunctionComponent.fs#L22-L27

@adelarsq
Copy link

adelarsq commented Sep 2, 2020

@AndrewMorsillo Did you manage to solve this problem?

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

3 participants