Next.js Discord

Discord Forum

Redux toolkit how to preload async function state

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
How would I pass an async function to the configureStore preloadedState?
import { configureStore } from '@reduxjs/toolkit';

export const store = configureStore({
    reducer: { main },
    preloadedState: loadState(),
});

store.subscribe(debounce(() => saveState(store.getState()), 500));

I cant use async loadState() cause it throws an error and theres no top level await in client components

0 Replies