MCPcopy Create free account
hub / github.com/SyntaxUI/syntaxui / SectionProvider

Function SectionProvider

src/components/SectionProvider.tsx:128–148  ·  view source on GitHub ↗
({
  sections,
  children,
}: {
  sections: Array<Section>
  children: React.ReactNode
})

Source from the content-addressed store, hash-verified

126 typeof window === 'undefined' ? useEffect : useLayoutEffect
127
128export 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
150export function useSectionStore<T>(selector: (state: SectionState) => T) {
151 let store = useContext(SectionStoreContext)

Callers

nothing calls this directly

Calls 2

createSectionStoreFunction · 0.85
useVisibleSectionsFunction · 0.85

Tested by

no test coverage detected