MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / SectionProvider

Function SectionProvider

apps/baseai.dev/src/components/SectionProvider.tsx:131–151  ·  view source on GitHub ↗
({
	sections,
	children
}: {
	sections: Array<Section>;
	children: React.ReactNode;
})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

createSectionStoreFunction · 0.85
useVisibleSectionsFunction · 0.85

Tested by

no test coverage detected