Add the dependency:
npm i react-navigation-helpers
IMPORTANT! You need install them.
"react": ">= 16.x.x",
"react-navigation": ">= 5.x.x"
- Use v0.2.0+ for ReactNavigation v5
- Use v0.1.0+ for ReactNavigation v4
Set the global level navigation reference into the NavigationContainer
import { isReadyRef, navigationRef } from "react-navigation-helpers";
React.useEffect(() => {
return () => (isReadyRef.current = false);
}, []);
<NavigationContainer
ref={navigationRef}
onReady={() => {
isReadyRef.current = true;
}}
>
{/* ... */}
</NavigationContainer>;
import * as NavigationService from "react-navigation-helpers";
NavigationService.navigate("home");
import * as NavigationService from "react-navigation-helpers";
NavigationService.push("home");
import * as NavigationService from "react-navigation-helpers";
NavigationService.pop();
import * as NavigationService from "react-navigation-helpers";
NavigationService.popToTop();
import * as NavigationService from "react-navigation-helpers";
NavigationService.back();
The usage does not change. Simply put your prop as the secondary prop as same as React Navigation itself.
import * as NavigationService from "react-navigation-helpers";
NavigationService.navigate("home", { data: myData, myId: "d1f01df1" });
import * as NavigationService from "react-navigation-helpers";
NavigationService.push("home", { data: myData, myId: "d1f01df1" });
const { data, id } = this.props.route.params;
Property | Type | Default | Description |
---|---|---|---|
navigate | function | function | navigate the selected screen |
push | function | function | push the selected screen |
goBack | function | function | back the previous screen |
pop | function | function | pop the previous screen |
popToTop | function | function | pop the top level of the screen |
reset | function | function | reset the navigator |
- [x]
LICENSE - [ ] Write an article about the lib on Medium
FreakyCoder, kurayogun@gmail.com
React Navigation Helpers Library is available under the MIT license. See the LICENSE file for more info.