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 c4117fd commit 8b2ecff
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/react-core/src/scalprum-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,18 @@ export function ScalprumProvider<T extends Record<string, any> = Record<string,
});
}, []);

const value = useMemo(
() => ({
config: state.appsConfig,
api: state.api,
initialized: true,
pluginStore: state.pluginStore,
}),
[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 8b2ecff

Please sign in to comment.