@tamagui/react-native-web-lite
Version:
React Native for Web
32 lines (31 loc) • 1.44 kB
JavaScript
import { StyleSheet } from "@tamagui/react-native-web-internals";
import { invariant } from "@tamagui/react-native-web-internals";
import { renderLegacy, hydrate, hydrateLegacy, render } from "../render/index";
import { AppContainer } from "./AppContainer";
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.js.map