useStoreLayouts
Reach for this hook when you need the full, flat collection of layout entities in the store, for example to build an index, search for a node, or react whenever any layout entity is added, removed, or changed. For working with a single entity, use useLayoutEntity.
Getting the controller
import { useStoreLayouts } from "@expivi/product-configurator";
const controller = useStoreLayouts(configurator);
Example
import { useStoreLayouts } from "@expivi/product-configurator";
const controller = useStoreLayouts(configurator);
// read the current list
console.log(`${controller.data.length} layout entities`);
// react to any change in the collection
const unsubscribe = controller.subscribe(entities => {
console.log("layout entities changed:", entities.length);
});
// later, when the component unmounts
unsubscribe();
API
data
Returns every LayoutEntity currently in the store as a flat array.
subscribe(callback)
Subscribes to changes of the layout entity collection. The callback receives the updated array. Returns an unsubscribe function; call it during cleanup to avoid leaks.