92 lines
3.1 KiB
JavaScript
92 lines
3.1 KiB
JavaScript
// Module ID: 1591
|
|
// Function ID: 1592
|
|
// Name: useNavigationState
|
|
// Dependencies: [32, 19, 21, 1577, 1521]
|
|
// Exports: NavigationStateListenerProvider, useNavigationState
|
|
|
|
// Module 1591 (useNavigationState)
|
|
import _slicedToArray from "_slicedToArray";
|
|
import importAllResult from "noop";
|
|
import { jsx } from "jsxProd";
|
|
|
|
const require = arg1;
|
|
let c4 = importAllResult;
|
|
const context = importAllResult.createContext(undefined);
|
|
|
|
export const useNavigationState = function useNavigationState(fn) {
|
|
const _require = fn;
|
|
if (typeof fn !== "function") {
|
|
const _Error2 = Error;
|
|
const _HermesInternal = HermesInternal;
|
|
const error = new Error("A selector function must be provided (got " + typeof fn + ").");
|
|
throw error;
|
|
} else {
|
|
let obj = importAllResult;
|
|
const store = importAllResult.useContext(closure_6);
|
|
if (null == store) {
|
|
const _Error = Error;
|
|
const error1 = new Error("Couldn't get the navigation state. Is your component inside a navigator?");
|
|
throw error1;
|
|
} else {
|
|
const getState = store.getState;
|
|
const subscribe = store.subscribe;
|
|
callback = callback(obj.useReducer((arg0) => arg0 + 1, 0), 2)[1];
|
|
const tmp14 = fn(getState());
|
|
obj = { select: null, selected: null };
|
|
obj[0] = fn;
|
|
obj[1] = tmp14;
|
|
let closure_5 = obj.useRef(obj);
|
|
const clientLayoutEffect = _require(subscribe[3]).useClientLayoutEffect(() => {
|
|
closure_5.current = { select: closure_0, selected: closure_4 };
|
|
});
|
|
const items = [getState, subscribe];
|
|
const effect = obj.useEffect(() => {
|
|
let select;
|
|
let selected;
|
|
let current = ref.current;
|
|
({ selected, select } = current);
|
|
if (!Object.is(selected, select(getState()))) {
|
|
callback();
|
|
}
|
|
return subscribe(function checkForUpdates() {
|
|
let select;
|
|
let selected;
|
|
const current = ref.current;
|
|
({ selected, select } = current);
|
|
if (!Object.is(selected, select(callback()))) {
|
|
callback2();
|
|
}
|
|
});
|
|
}, items);
|
|
return tmp14;
|
|
}
|
|
}
|
|
};
|
|
export const NavigationStateListenerProvider = function NavigationStateListenerProvider(getState) {
|
|
let children;
|
|
let state;
|
|
getState = getState.getState;
|
|
let importDefault;
|
|
let dependencyMap;
|
|
({ state, children } = getState);
|
|
importDefault = importAllResult.useRef([]);
|
|
const tmp = importDefault(1521)((arg0) => {
|
|
let closure_0 = arg0;
|
|
let current = ref.current;
|
|
current.push(arg0);
|
|
return () => {
|
|
const current = outer1_1.current;
|
|
outer1_1.current = current.filter((arg0) => arg0 !== closure_0);
|
|
};
|
|
});
|
|
dependencyMap = tmp;
|
|
let obj = getState(1577);
|
|
const items = [state];
|
|
const clientLayoutEffect = obj.useClientLayoutEffect(() => {
|
|
const current = ref.current;
|
|
const item = current.forEach((arg0) => arg0());
|
|
}, items);
|
|
const items1 = [getState, tmp];
|
|
obj = { value: importAllResult.useMemo(() => ({ getState, subscribe: c2 }), items1), children };
|
|
return <redux.Provider value={importAllResult.useMemo(() => ({ getState, subscribe: c2 }), items1)}>{children}</redux.Provider>;
|
|
};
|