one
Version:
One is a new React Framework that makes Vite serve both native and web.
52 lines (50 loc) • 1.59 kB
JavaScript
"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { createNavigatorFactory, StackActions, StackRouter, useNavigationBuilder } from "@react-navigation/native";
import { useEffect } from "react";
import { WebStackView } from "./WebStackView.native.js";
function WebStackNavigator(param) {
var {
initialRouteName,
children,
screenOptions,
...rest
} = param;
var {
state,
navigation,
descriptors,
NavigationContent,
describe
} = useNavigationBuilder(StackRouter, {
...rest,
children,
screenOptions,
initialRouteName
});
useEffect(function () {
var _navigation_addListener;
return navigation === null || navigation === void 0 ? void 0 : (_navigation_addListener = navigation.addListener) === null || _navigation_addListener === void 0 ? void 0 : _navigation_addListener.call(navigation, "tabPress", function (e) {
var isFocused = navigation.isFocused();
requestAnimationFrame(function () {
if (state.index > 0 && isFocused && !e.defaultPrevented) {
navigation.dispatch({
...StackActions.popToTop(),
target: state.key
});
}
});
});
}, [navigation, state.index, state.key]);
return /* @__PURE__ */_jsx(NavigationContent, {
children: /* @__PURE__ */_jsx(WebStackView, {
state,
navigation,
descriptors,
describe
})
});
}
var createWebStackNavigator = createNavigatorFactory(WebStackNavigator);
export { createWebStackNavigator };
//# sourceMappingURL=WebStackNavigator.native.js.map