UNPKG

@dr.pogodin/react-utils

Version:

Collection of generic ReactJS components and utils

7 lines 1.06 kB
// Initialization of client-side code. /* global document */import{createRoot,hydrateRoot}from"react-dom/client";import{HelmetProvider}from"@dr.pogodin/react-helmet";import{BrowserRouter}from"react-router";import{GlobalStateProvider}from"@dr.pogodin/react-global-state";import getInj from"./getInj.js";import{jsx as _jsx}from"react/jsx-runtime";/** * Prepares and launches the app at client side. * @param Application Root application component * @param [options={}] Optional. Additional settings. */export default function Launch(Application,options={}){const container=document.getElementById("react-view");if(!container)throw Error("Failed to find container for React app");const scene=/*#__PURE__*/_jsx(GlobalStateProvider,{initialState:getInj().ISTATE??options.initialState,children:/*#__PURE__*/_jsx(BrowserRouter,{children:/*#__PURE__*/_jsx(HelmetProvider,{children:/*#__PURE__*/_jsx(Application,{})})})});if(options.dontHydrate){const root=createRoot(container);root.render(scene)}else hydrateRoot(container,scene)} //# sourceMappingURL=index.js.map