({
sections,
children,
}: {
sections: Array<Section>
children: React.ReactNode
})
| 126 | typeof window === 'undefined' ? useEffect : useLayoutEffect |
| 127 | |
| 128 | export function SectionProvider({ |
| 129 | sections, |
| 130 | children, |
| 131 | }: { |
| 132 | sections: Array<Section> |
| 133 | children: React.ReactNode |
| 134 | }) { |
| 135 | let [sectionStore] = useState(() => createSectionStore(sections)) |
| 136 | |
| 137 | useVisibleSections(sectionStore) |
| 138 | |
| 139 | useIsomorphicLayoutEffect(() => { |
| 140 | sectionStore.setState({ sections }) |
| 141 | }, [sectionStore, sections]) |
| 142 | |
| 143 | return ( |
| 144 | <SectionStoreContext.Provider value={sectionStore}> |
| 145 | {children} |
| 146 | </SectionStoreContext.Provider> |
| 147 | ) |
| 148 | } |
| 149 | |
| 150 | export function useSectionStore<T>(selector: (state: SectionState) => T) { |
| 151 | let store = useContext(SectionStoreContext) |
nothing calls this directly
no test coverage detected