/
WaterfallRenderContext.mjs
32 lines (27 loc) · 1.01 KB
/
WaterfallRenderContext.mjs
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
26
27
28
29
30
31
32
// @ts-check
import React from "react";
/** @typedef {import("./waterfallRender.mjs").DeclareLoading} DeclareLoading */
/** @typedef {import("./waterfallRender.mjs").default} waterfallRender */
/**
* [React context](https://reactjs.org/docs/context.html) for making the
* {@link DeclareLoading declare loading function} available within components
* when rendering with {@linkcode waterfallRender}.
* @type {React.Context<DeclareLoading | undefined>}
* @example
* Use within a component with the React hook
* [`useContext`](https://reactjs.org/docs/hooks-reference.html#usecontext).
*
* ```js
* import React from "react";
* import WaterfallRenderContext from "react-waterfall-render/WaterfallRenderContext.mjs";
* ```
*
* ```js
* const declareLoading = React.useContext(WaterfallRenderContext);
* ```
*/
const WaterfallRenderContext = React.createContext(
/** @type {DeclareLoading | undefined} */ (undefined)
);
WaterfallRenderContext.displayName = "WaterfallRenderContext";
export default WaterfallRenderContext;