Skip to content

Commit

Permalink
fix(react): memoize provider value
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Sep 24, 2024
1 parent baa5762 commit a7b95eb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/react-core/src/scalprum-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,20 @@ export function ScalprumProvider<T extends Record<string, any> = Record<string,
// @ts-ignore
}, [props.api, props.config, props.scalprum]);

const value = useMemo(
() => ({
config: state.appsConfig,
api: state.api,
initialized: true,
pluginStore: state.pluginStore,
}),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
[props.api, props.config, props.scalprum, state],
);

return (
<ScalprumContext.Provider
value={{
config: state.appsConfig,
api: state.api,
initialized: true,
pluginStore: state.pluginStore,
}}
>
<ScalprumContext.Provider value={value}>
<PluginStoreProvider store={state.pluginStore}>{props.children}</PluginStoreProvider>
</ScalprumContext.Provider>
);
Expand Down

0 comments on commit a7b95eb

Please sign in to comment.