expo-router
Version:
Expo Router is a file-based router for React Native and web applications.
70 lines (68 loc) • 2.37 kB
JavaScript
'use client';
;
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
Screen: null,
isScreen: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: Object.getOwnPropertyDescriptor(all, name).get
});
}
_export(exports, {
get Screen () {
return Screen;
},
get isScreen () {
return isScreen;
}
});
function _react() {
const data = require("react");
_react = function() {
return data;
};
return data;
}
const _useNavigation = require("../useNavigation");
const _useSafeLayoutEffect = require("./useSafeLayoutEffect");
function Screen({ name, options }) {
if (name) {
throw new Error(`The name prop on the Screen component may only be used when it is inside a Layout route`);
}
const navigation = (0, _useNavigation.useNavigation)();
(0, _useSafeLayoutEffect.useSafeLayoutEffect)(()=>{
if (options && Object.keys(options).length) {
// React Navigation will infinitely loop in some cases if an empty object is passed to setOptions.
// https://github.com/expo/router/issues/452
navigation.setOptions(options);
}
}, [
navigation,
options
]);
return null;
}
function isScreen(child, contextKey) {
if (/*#__PURE__*/ (0, _react().isValidElement)(child) && child && child.type === Screen) {
if (typeof child.props === 'object' && child.props && 'name' in child.props && !child.props.name) {
throw new Error(`<Screen /> component in \`default export\` at \`app${contextKey}/_layout\` must have a \`name\` prop when used as a child of a Layout Route.`);
}
if (process.env.NODE_ENV !== 'production') {
if ([
'children',
'component',
'getComponent'
].some((key)=>child.props && typeof child.props === 'object' && key in child.props)) {
throw new Error(`<Screen /> component in \`default export\` at \`app${contextKey}/_layout\` must not have a \`children\`, \`component\`, or \`getComponent\` prop when used as a child of a Layout Route`);
}
}
return true;
}
return false;
}
//# sourceMappingURL=Screen.js.map