UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

19 lines (18 loc) 651 B
import { createContext, useContext, useId } from "react"; const ServerHeadInsertions = {}; const getServerHeadInsertions = id => { if (ServerHeadInsertions[id]) { return Object.values(ServerHeadInsertions[id]); } }; const ServerRenderID = createContext(""); const useServerHeadInsertion = callback => { if (typeof window == "undefined") { const insertionID = useId(); const id = useContext(ServerRenderID); ServerHeadInsertions[id] ||= {}; ServerHeadInsertions[id][insertionID] = callback; } }; export { ServerRenderID, getServerHeadInsertions, useServerHeadInsertion }; //# sourceMappingURL=useServerHeadInsertion.mjs.map