react-navigation / hooks

React hooks for convenient react-navigation use
https://reactnavigation.org
MIT License
576 stars 36 forks source link

fix: Use @react-navigation/core #61

Closed vomchik closed 4 years ago

vomchik commented 4 years ago

This PR fix issue with a web version.

Related https://github.com/react-navigation/hooks/issues/59

slorber commented 4 years ago

Hi and thanks.

Can you explain what this is fixing and how did you test your code?

Not totally sure what are the impacts, and don't like the "any" context. In community typedefs, it is export const NavigationContext: React.Context<NavigationScreenProp<NavigationRoute>>;

vomchik commented 4 years ago

@slorber Hi! The common issue it that lib directly import react-native which contains import of native implementation https://github.com/react-navigation/react-navigation/blob/master/src/react-navigation.js#L2. So i have changed import to react-native/core.

vomchik commented 4 years ago

also, I have updated the typings for the core module

satya164 commented 4 years ago

We don't recommend libraries (or app code) to import from /core as it can easily lead to duplicated instances of /core leading to issues.

As a workaround, you can alias react-navigation to @react-navigation/core in your webpack config if that works for you.

vomchik commented 4 years ago

I see. I'm using CRA, so I don't have access to webpack config. Also not really want to use tools for overriding a default config.

vomchik commented 4 years ago

Should I close my PR?

satya164 commented 4 years ago

@vomchik you can also try patch-package to patch the import until we figure out a better way.

vomchik commented 4 years ago

Cool! I will try it. Thanks.

slorber commented 4 years ago

Thanks, let's close this for now