Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

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

Closed
CptFabulouso opened this issue Nov 22, 2019 · 3 comments
Closed

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

CptFabulouso opened this issue Nov 22, 2019 · 3 comments

Comments

@CptFabulouso
Copy link

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
Copy link
Member

Ashoat commented Nov 22, 2019

@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
Copy link
Member

Ashoat commented Nov 22, 2019

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.

@Ashoat Ashoat closed this as completed Nov 22, 2019
@CptFabulouso
Copy link
Author

Nicely written, thanks a lot

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

No branches or pull requests

2 participants