-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Upgrade to React Navigation 6.0 #43
Comments
In order to use React Navigation 6.x, I patched I'm sure I haven't fixed everything :) but I think what I have would be enough for most use cases. Would you like me to open a PR with the changes? |
Please do. @Freddy03h did you started something already or not? |
Not yet, I was busy on my react-native-web release ^^ |
@Freddy03h ok nice. Thanks for your feedback. If you and @vknez are successfully using it I guess I will merge as soon as you give me your go :) Then I will update my app as soon as I can. |
@vknez Did you also start something for the |
@Freddy03h No, I didn't plan to work on that in near future. In my app web routes are defined in TypeScript, so it isn't urgent. My bigger issue right now is how to use the |
@vknez I read real quick your comment but is this helping you https://github.com/MoOx/LifeTime/blob/05eb85efc29223e6f9340398be8e4b2c4dd65da1/src/screens/GoalsScreen.res#L65 ? If I understand correctly you are wondering how to specify navigators/params. Here if you find related module you should get your answer if I am correct :) |
@vknez Ok I'll try to propose something for linking this week :) I think the point @vknez mentioning is that routes and theirs params are barely connected. In your example @MoOx, you can navigate to On my app I created a variant for my routes and custom hooks on top of // example code
open ReactNavigation
module StackParams = {
type params = {
id: string,
initialScrollVolume: option<string>,
initialEditMode: option<bool>,
initialVolumesChecked: option<Belt.Set.String.t>,
}
@obj
external makeParams: (
~initialScrollVolume: string=?,
~initialEditMode: bool=?,
~initialVolumesChecked: Belt.Set.String.t=?,
~id: string,
unit,
) => params = ""
}
include Stack.Make(StackParams)
type routes =
| Volume(string)
| Edition(string, option<string>, option<bool>, option<Belt.Set.String.t>)
| Serie(string)
| Author(string)
| Publisher(string)
let useNavigationRoute = (route: routes): (
option<string>,
unit => unit,
) => {
let navigation = ReactNavigation.Native.useNavigation()
let (routeName, params) = switch route {
| Volume(id) => ("volumeDetail", StackParams.makeParams(~id, ()))
| Edition(id, initialScrollVolume, initialEditMode, initialVolumesChecked) => (
"editionDetail",
StackParams.makeParams(
~initialScrollVolume?,
~initialEditMode?,
~initialVolumesChecked?,
~id,
(),
),
)
| Serie(id) => ("serieDetail", StackParams.makeParams(~id, ()))
| Author(id) => ("authorDetail", StackParams.makeParams(~id, ()))
| Publisher(id) => ("publisherDetail", StackParams.makeParams(~id, ()))
}
(
None, // on my RNW app it's used to return a string for href prop
() => navigation->Navigation.navigateWithParams(routeName, params)
)
} It's a custom abstract layer on top of react-navigation method. It's more than bindings, so I don't know if we plan to add helpers in In my case, this abstraction layer help me for sharing screens and components between Maybe it could be a library on it's own, but for now, I don't know how to do it without too much boilerplate (maybe it's a bad idea). |
React Navigation 6.0 is coming! But don't worry it's still in beta On the way to React Navigation 6.0
They also wrote a really clean upgrading post that will help us migrating Upgrading from 5.x
Interesting part I noticed is changes on the Linking config. For now we don't have linking config on the bindings, I created my own on my app but never backport it here because some weird case that lead to be to tied with the app in the end.
With changes on V6 I think it will be doable, I want to test it!
This upgrade will wait Rescript Migration #42 I think.
The text was updated successfully, but these errors were encountered: