@tamagui/react-native-web-lite
Version:
React Native for Web
52 lines (51 loc) • 1.83 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import "react";
import { StyleSheet } from "@tamagui/react-native-web-internals";
import { invariant } from "@tamagui/react-native-web-internals";
import renderLegacy, { hydrate, hydrateLegacy, render } from "../render/index.native.js";
import AppContainer from "./AppContainer.native.js";
function renderApplication(RootComponent) {
var WrapperComponent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null,
callback = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function () {},
options = arguments.length > 3 ? arguments[3] : void 0,
{
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) {
var element = /* @__PURE__ */_jsx(AppContainer, {
WrapperComponent,
rootTag: {},
children: /* @__PURE__ */_jsx(RootComponent, {
...initialProps
})
}),
getStyleElement = function (props) {
var sheet = StyleSheet.getSheet();
return /* @__PURE__ */_jsx("style", {
...props,
dangerouslySetInnerHTML: {
__html: sheet.textContent
},
id: sheet.id
});
};
return {
element,
getStyleElement
};
}
export { renderApplication as default, getApplication };
//# sourceMappingURL=renderApplication.native.js.map