one
Version:
One is a new React Framework that makes Vite serve both native and web.
39 lines (37 loc) • 1.44 kB
JavaScript
"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { Children, isValidElement, useMemo } from "react";
import { StackHeaderComponent, appendStackHeaderPropsToOptions } from "./StackHeaderComponent.native.js";
import { Screen } from "../../views/Screen.native.js";
function StackScreen(param) {
var {
children,
options,
...rest
} = param,
updatedOptions = useMemo(function () {
return appendScreenStackPropsToOptions(options ?? {}, {
children
});
}, [options, children]);
return /* @__PURE__ */_jsx(Screen, {
...rest,
options: updatedOptions
});
}
function appendScreenStackPropsToOptions(options, props) {
var updatedOptions = {
...options,
...props.options
};
function appendChildOptions(child, options2) {
if (child.type === StackHeaderComponent) return appendStackHeaderPropsToOptions(options2, child.props);
var _child_type_name;
return console.warn(`Warning: Unknown child element passed to Stack.Screen: ${(_child_type_name = child.type.name) !== null && _child_type_name !== void 0 ? _child_type_name : child.type}`), options2;
}
return Children.forEach(props.children, function (child) {
/* @__PURE__ */isValidElement(child) && (updatedOptions = appendChildOptions(child, updatedOptions));
}), updatedOptions;
}
export { StackScreen, appendScreenStackPropsToOptions };
//# sourceMappingURL=StackScreen.native.js.map