🐛 Fix incorrect param name in reducer utils

This commit is contained in:
Philipp Stracker 2024-11-20 16:32:07 +01:00
parent 650858a50e
commit 4ae61dfb58
No known key found for this signature in database

View file

@ -30,10 +30,10 @@ const updateObject = ( oldObject, newValues, allowedKeys = {} ) => ( {
* @return {[Function, Function]} An array containing setTransient and setPersistent functions.
*/
export const createSetters = ( defaultTransient, defaultPersistent ) => {
const setTransient = ( oldState, newValues ) =>
const setTransient = ( oldState, newValues = {} ) =>
updateObject( oldState, newValues, defaultTransient );
const setPersistent = ( oldState, newValues ) => ( {
const setPersistent = ( oldState, newValues = {} ) => ( {
...oldState,
data: updateObject( oldState.data, newValues, defaultPersistent ),
} );
@ -67,7 +67,7 @@ export const createReducer = (
return function reducer( state = initialState, action ) {
if ( Object.hasOwnProperty.call( handlers, action.type ) ) {
return handlers[ action.type ]( state, action.data );
return handlers[ action.type ]( state, action.payload ?? {} );
}
return state;