MCPcopy Index your code
hub / github.com/plotly/dash / DashContextProvider

Function DashContextProvider

dash/dash-renderer/src/wrapper/DashContext.tsx:48–117  ·  view source on GitHub ↗
(props: DashContextProviderProps)

Source from the content-addressed store, hash-verified

46};
47
48export function DashContextProvider(props: DashContextProviderProps) {
49 const {children, componentPath} = props;
50
51 const stringPath = useMemo<string>(
52 () => JSON.stringify(componentPath),
53 [componentPath]
54 );
55 const store = useStore();
56
57 const isLoading = useCallback(
58 (options?: LoadingOptions) => {
59 const {extraPath, rawPath, filterFunc} = options || {};
60 let loadingPath = [stringPath];
61 if (extraPath) {
62 loadingPath = [
63 JSON.stringify(concat(componentPath, extraPath))
64 ];
65 } else if (rawPath) {
66 loadingPath = [JSON.stringify(rawPath)];
67 }
68 const loading = pathOr(
69 [],
70 loadingPath,
71 (store.getState() as any).loading
72 );
73 return filterFunc
74 ? loading.filter(filterFunc).length > 0
75 : loading.length > 0;
76 },
77 [stringPath]
78 );
79
80 const useLoading = useCallback(
81 (options?: LoadingOptions) => {
82 const {filterFunc, extraPath, rawPath} = options || {};
83 return useSelector((state: any) => {
84 let loadingPath = [stringPath];
85 if (extraPath) {
86 loadingPath = [
87 JSON.stringify(concat(componentPath, extraPath))
88 ];
89 } else if (rawPath) {
90 loadingPath = [JSON.stringify(rawPath)];
91 }
92 const load = pathOr([], loadingPath, state.loading);
93 if (filterFunc) {
94 return load.filter(filterFunc).length > 0;
95 }
96 return load.length > 0;
97 });
98 },
99 [stringPath]
100 );
101
102 const ctxValue = useMemo(() => {
103 return {
104 componentPath,
105 isLoading,

Callers

nothing calls this directly

Calls 4

useMemoFunction · 0.90
useCallbackFunction · 0.90
filterMethod · 0.80
getStateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…