I am having the following problem setting up my redux store in a react app with preloadedState: I am relying on data from an async function. I tried to solve it with top level await, but I couldn't enable it via the webpack.config.js file (how to enable top level await in reactjs).
my first question is if react (^18.2.0) supports top level await?
my second question is if there is a workaround to my problem?
async function preloadState() {
const selectionState = await window.browser.storage.local.get("selectionState");
const externalTimings = await window.browser.storage.local.get("externalTimings");
return {
'selectionState': selectionState,
'externalTimings': externalTimings
}
}
export const store = configureStore({
preloadedState: preloadState(),
reducer: {
selectionState: selectionStateSliceReducer,
externalTimings: externalTimingsReducer,
},
})