({ sections, children })
| 103 | typeof window === 'undefined' ? useEffect : useLayoutEffect |
| 104 | |
| 105 | export function SectionProvider({ sections, children }) { |
| 106 | let [sectionStore] = useState(() => createSectionStore(sections)) |
| 107 | |
| 108 | useVisibleSections(sectionStore) |
| 109 | |
| 110 | useIsomorphicLayoutEffect(() => { |
| 111 | sectionStore.setState({ sections }) |
| 112 | }, [sectionStore, sections]) |
| 113 | |
| 114 | return ( |
| 115 | <SectionStoreContext.Provider value={sectionStore}> |
| 116 | {children} |
| 117 | </SectionStoreContext.Provider> |
| 118 | ) |
| 119 | } |
| 120 | |
| 121 | export function useSectionStore(selector) { |
| 122 | let store = useContext(SectionStoreContext) |
nothing calls this directly
no test coverage detected