diff --git a/package.json b/package.json index 430d7b4..ec01529 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "files": [ "dist" ], - "version": "4.5.0", + "version": "4.6.0-next.1", "main": "dist/little-state-machine.js", "module": "dist/little-state-machine.es.js", "unpkg": "dist/little-state-machine.umd.js", diff --git a/src/stateMachine.tsx b/src/stateMachine.tsx index a3fa2a7..b83b176 100644 --- a/src/stateMachine.tsx +++ b/src/stateMachine.tsx @@ -37,7 +37,7 @@ const actionTemplate = setState: React.Dispatch>, callback: TCallback, ) => - (payload: Parameters[1]) => { + (payload: Parameters[1], options?: { skipRender: boolean }) => { if (process.env.NODE_ENV !== 'production') { window[STORE_ACTION_NAME] = callback.name; } @@ -52,7 +52,7 @@ const actionTemplate = ); } - setState(storeFactory.state); + (!options || !options.skipRender) && setState(storeFactory.state); storeFactory.options.persist !== PERSIST_BEFORE_UNLOAD && storeFactory.saveStore(); }; diff --git a/src/types.ts b/src/types.ts index dbd88b1..b2e83cc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,7 +10,7 @@ export type ActionsOutput< TCallback extends AnyCallback, TActions extends AnyActions, > = { - [K in keyof TActions]: (payload?: Parameters[1]) => void; + [K in keyof TActions]: (payload?: Parameters[1], options?: { skipRender: boolean }) => void; }; export type StateMachineContextValue = {