From cca027567cb8cb6bb2f09b2c9bc69ffb7e22da73 Mon Sep 17 00:00:00 2001 From: Andrew Baldwin Date: Mon, 2 Dec 2024 14:06:44 -0500 Subject: [PATCH] Add create store export --- locust/webui/src/lib.tsx | 2 +- locust/webui/src/redux/store.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/locust/webui/src/lib.tsx b/locust/webui/src/lib.tsx index a91bcdc756..7307bf35c8 100644 --- a/locust/webui/src/lib.tsx +++ b/locust/webui/src/lib.tsx @@ -33,7 +33,7 @@ export { default as Logo } from 'assets/Logo'; export { default as Modal } from 'components/Modal/Modal'; export { default as useCreateTheme } from 'hooks/useCreateTheme'; export { tabConfig } from 'components/Tabs/Tabs.constants'; -export { store as locustStore } from 'redux/store'; +export { store as locustStore, createStore as createLocustStore } from 'redux/store'; export { pushQuery } from 'utils/url'; export type { IRootState } from 'redux/store'; diff --git a/locust/webui/src/redux/store.ts b/locust/webui/src/redux/store.ts index e781ad42cc..faf29d3f93 100644 --- a/locust/webui/src/redux/store.ts +++ b/locust/webui/src/redux/store.ts @@ -1,12 +1,19 @@ import { configureStore } from '@reduxjs/toolkit'; import { api } from 'redux/api/swarm'; -import rootReducer from 'redux/slice/root.slice'; +import rootReducer, { IRootState } from 'redux/slice/root.slice'; export const store = configureStore({ reducer: rootReducer, middleware: getDefaultMiddleware => getDefaultMiddleware().concat(api.middleware), }); +export const createStore = (preloadedState: Partial) => + configureStore({ + reducer: rootReducer, + middleware: getDefaultMiddleware => getDefaultMiddleware().concat(api.middleware), + preloadedState, + }); + export type { IRootState, Action } from 'redux/slice/root.slice'; export default configureStore;