react-navigation / redux-helpers

Redux middleware and utils for React Navigation
Other
296 stars 43 forks source link

Is @react-navigation/core needed? v4.0.1 #103

Closed CptFabulouso closed 4 years ago

CptFabulouso commented 4 years ago

I am confused if I should add @react-navigation/core package to my project, why is it needed? I tried removing it and everything still seems to work, is it just for typings? It's mentioned in changelogs, but not in readme.

Project uses Flow, but typings for react-navigation are not imported. used versions: "react-navigation": "^4.0.10", "react-navigation-redux-helpers": "^4.0.1", "react-navigation-stack": "^1.10.3",

Ashoat commented 4 years ago

@react-navigation/core is listed as a peer dependency because we import some utilities from there, but don't want to lock onto a specific version of react-navigation, and instead want to defer version selection to the user.

We could specify react-navigation as the peer dependency instead, which is what I tried in 4.0.0. Everything exported by @react-navigation/core is also exported by react-navigation. However, this breaks web support, which doesn't actually use the react-navigation package at all.

Using react-navigation directly would have a couple small benefits. One is that it would reduce the amount of peer dependency complaints yarn/npm make. They don't like that the version specification of @react-navigation/core is nested within another dependency (react-navigation) in your package.json, and as such don't consider it to technically be a "peer" dependency. But these errors can be safely ignored. The other benefit is that if you're using Flow, you end up having to install libdefs for both react-navigation as well as @react-navigation/core under the current setup. If we just used react-navigation, the user would only need one libdef.

These small benefits are outweighed by the cost of breaking web support, which is why we're keeping @react-navigation/core as the peer dependency.

Ashoat commented 4 years ago

To your questions:

I am confused if I should add @react-navigation/core package to my project

If you're not importing anything directly from it, you don't need to bother. It is in your project by virtue of being a dependency of react-navigation. You will get yarn/npm errors about the peer dependency for the reasons mentioned above, but you can safely ignore them.

is it just for typings?

The typing for the mainline React Navigation packages (react-navigation, @react-navigation/core, etc.) are maintained via flow-typed. This project is the only one in the React Navigation org that hosts Flow types in-package.

CptFabulouso commented 4 years ago

Nicely written, thanks a lot