MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / WidgetContextProvider

Function WidgetContextProvider

src/canvas/context/widgetContext.js:8–23  ·  view source on GitHub ↗
({ children })

Source from the content-addressed store, hash-verified

6
7
8export const WidgetContextProvider = ({ children }) => {
9
10 const [activeWidget, setActiveWidget] = useState(null)
11 const [widgets, setWidgets] = useState([]) // stores the mapping to widgetRefs, stores id and WidgetType, later used for rendering [{id: , widgetType: WidgetClass, children: [], parent: "", initialData: {}}]
12
13 // don't useState here because the refs are changing often
14 const widgetRefs = useRef({}) // stores the actual refs to the widgets inside the canvas {id: ref, id2, ref2...}
15
16
17 return (
18 <WidgetContext.Provider value={{ widgets, setWidgets, widgetRefs,
19 activeWidget, setActiveWidget }}>
20 {children}
21 </WidgetContext.Provider>
22 )
23}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected