UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

2 lines (1 loc) 623 B
import{jsx as _}from"react/jsx-runtime";import{useState as o,useRef as r,useEffect as T}from"react";import t from"./top-modal.context.js";const n=({children:n})=>{const[i,A]=o(null),E=r(!0);return E.current&&(window.__CARBON_INTERNALS_MODAL_SETTER_LIST||(window.__CARBON_INTERNALS_MODAL_SETTER_LIST=[]),window.__CARBON_INTERNALS_MODAL_SETTER_LIST.push(A),E.current=!1),T((()=>()=>{var _;window.__CARBON_INTERNALS_MODAL_SETTER_LIST=null===(_=window.__CARBON_INTERNALS_MODAL_SETTER_LIST)||void 0===_?void 0:_.filter((_=>_!==A))}),[]),_(t.Provider,{value:{topModal:i},children:n})};export{n as TopModalProvider,n as default};