UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

56 lines (55 loc) 1.76 kB
import { TabRouter as RNTabRouter } from "@react-navigation/native"; function ExpoTabRouter(options) { const rnTabRouter = RNTabRouter(options); const router = { ...rnTabRouter, getStateForAction(state, action, options2) { if (action.type === "REPLACE") { const payload = action.payload; return router.getStateForAction(state, { type: "JUMP_TO", source: action.source, target: action.target, payload: { name: payload?.name ?? "", params: payload?.params } }, options2); } if (action.type !== "JUMP_TO") { return rnTabRouter.getStateForAction(state, action, options2); } const route = state.routes.find(route2 => route2.name === action.payload.name); if (!route) { return null; } let shouldReset = !state.history.some(item => item.key === route?.key) && !route.state; if (!shouldReset && "resetOnFocus" in action.payload && action.payload.resetOnFocus) { shouldReset = state.routes[state.index].key !== route.key; } if (shouldReset) { options2.routeParamList[route.name] = { ...options2.routeParamList[route.name] }; state = { ...state, routes: state.routes.map(r => { if (r.key !== route.key) { return r; } return { ...r, state: void 0 }; }) }; return rnTabRouter.getStateForAction(state, action, options2); } else { return rnTabRouter.getStateForRouteFocus(state, route.key); } } }; return router; } export { ExpoTabRouter }; //# sourceMappingURL=TabRouter.mjs.map