Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions packages/wrapper/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
NextComponentType,
NextPageContext,
} from 'next';
import {useDispatch} from 'react-redux';
import {useDispatch,batch} from 'react-redux';

/**
* Quick note on Next.js return types:
Expand Down Expand Up @@ -186,14 +186,16 @@ const getStates = ({
};

const dispatchStates = (dispatch: Dispatch, states: PageProps, config: Config<any>) =>
getStates(states).forEach((actions, source) =>
getDeserialized(actions, config).forEach(action =>
dispatch({
...action,
meta: {...(action as any).meta, source},
}),
),
);
batch(() => {
getStates(states).forEach((actions, source) =>
getDeserialized(actions, config).forEach(action =>
dispatch({
...action,
meta: {...(action as any).meta, source},
}),
),
)
});

export const createWrapper = <S extends Store>(makeStore: MakeStore<S>, config: Config<S> = {}) => {
const makeProps = async function <P extends Object>({
Expand Down