Skip to content

Commit

Permalink
feat: return new state referene in block editor reducers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedant-Gandhi committed Dec 27, 2024
1 parent 538f03d commit 7895ee9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const withBlockTree =
const newState = reducer( state, action );

if ( newState === state ) {
return state;
return { ...state };
}

newState.tree = state.tree ? state.tree : new Map();
Expand Down Expand Up @@ -452,7 +452,7 @@ function withPersistentBlockChange( reducer ) {
if ( explicitPersistent !== undefined ) {
nextIsPersistentChange = explicitPersistent;
return nextIsPersistentChange === nextState.isPersistentChange
? nextState
? { ...nextState }
: {
...nextState,
isPersistentChange: nextIsPersistentChange,
Expand All @@ -471,7 +471,7 @@ function withPersistentBlockChange( reducer ) {

nextIsPersistentChange = state?.isPersistentChange ?? true;
if ( state.isPersistentChange === nextIsPersistentChange ) {
return state;
return { ...state };
}

return {
Expand All @@ -494,7 +494,7 @@ function withPersistentBlockChange( reducer ) {
markNextChangeAsNotPersistent =
action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';

return nextState;
return { ...nextState };
};
}

Expand Down

0 comments on commit 7895ee9

Please sign in to comment.