mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 19:01:38 +03:00
30 lines
638 B
JavaScript
30 lines
638 B
JavaScript
import { NavigationActions } from 'react-navigation';
|
|
|
|
let _navigator;
|
|
|
|
let navigationStack = [];
|
|
|
|
const setTopLevelNavigator = (navigatorRef) => {
|
|
_navigator = navigatorRef;
|
|
if (navigationStack.length > 0) {
|
|
navigationStack.forEach((item) => navigate(item));
|
|
navigationStack = [];
|
|
}
|
|
};
|
|
|
|
const navigate = (navigationProps) => {
|
|
if (!_navigator) {
|
|
navigationStack.push(navigationProps);
|
|
} else {
|
|
_navigator.dispatch(
|
|
NavigationActions.navigate({
|
|
...navigationProps,
|
|
}),
|
|
);
|
|
}
|
|
};
|
|
|
|
// add other navigation functions that you need and export them
|
|
|
|
export { navigate, setTopLevelNavigator };
|