UNPKG

@tamagui/react-native-web-lite

Version:
46 lines (45 loc) 1.54 kB
import { StyleSheet } from "@tamagui/react-native-web-internals"; import { invariant } from "@tamagui/react-native-web-internals"; import { renderLegacy, hydrate, hydrateLegacy, render } from "../render/index.mjs"; import { AppContainer } from "./AppContainer.mjs"; import { jsx } from "react/jsx-runtime"; function renderApplication(RootComponent, WrapperComponent = null, callback = () => {}, options) { const { hydrate: shouldHydrate, initialProps, mode, rootTag } = options, renderFn = shouldHydrate ? mode === "concurrent" ? hydrate : hydrateLegacy : mode === "concurrent" ? render : renderLegacy; return invariant(rootTag, "Expect to have a valid rootTag, instead got ", rootTag), renderFn(/* @__PURE__ */jsx(AppContainer, { WrapperComponent, ref: callback, rootTag, children: /* @__PURE__ */jsx(RootComponent, { ...initialProps }) }), rootTag); } function getApplication(RootComponent, initialProps, WrapperComponent) { return { element: /* @__PURE__ */jsx(AppContainer, { WrapperComponent, rootTag: {}, children: /* @__PURE__ */jsx(RootComponent, { ...initialProps }) }), getStyleElement: props => { const sheet = StyleSheet.getSheet(); return /* @__PURE__ */jsx("style", { ...props, dangerouslySetInnerHTML: { __html: sheet.textContent }, id: sheet.id }); } }; } export { getApplication, renderApplication }; //# sourceMappingURL=renderApplication.mjs.map