one
Version:
One is a new React Framework that makes Vite serve both native and web.
42 lines (41 loc) • 2.03 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var TabRouter_exports = {};
__export(TabRouter_exports, {
ExpoTabRouter: () => ExpoTabRouter
});
module.exports = __toCommonJS(TabRouter_exports);
var import_native = require("@react-navigation/native");
function ExpoTabRouter(options) {
const rnTabRouter = (0, import_native.TabRouter)(options);
return {
...rnTabRouter,
getStateForAction(state, action, 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;
return !shouldReset && "resetOnFocus" in action.payload && action.payload.resetOnFocus && (shouldReset = state.routes[state.index].key !== route.key), shouldReset ? (options2.routeParamList[route.name] = {
...options2.routeParamList[route.name]
}, state = {
...state,
routes: state.routes.map((r) => r.key !== route.key ? r : { ...r, state: void 0 })
}, rnTabRouter.getStateForAction(state, action, options2)) : rnTabRouter.getStateForRouteFocus(state, route.key);
}
};
}
//# sourceMappingURL=TabRouter.js.map