Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 11x 23x | import { createContext, useContext } from 'react';
/**
* One tree-scoped named data layer pushed by a `DataHandler`.
* @typedef {Object} DataLayer
* @property {string} name - the DataHandler `name` prop (the lookup key)
* @property {*} value - that DataHandler's current handler-managed data
*/
/**
* Ancestor stack of `{ name, value }` from nested DataHandlers.
* Root is `[]`. Lookup walks from the end (nearest wins).
* @type {import('react').Context<DataLayer[]>}
*/
export const DataLayerContext = createContext([]);
/**
* The ancestor DataHandler layer stack for this position in the tree
* (empty array at the root / outside any DataHandler).
* @returns {DataLayer[]}
*/
export function useDataLayers() {
return useContext(DataLayerContext);
}
|