Skip to content

Commit

Permalink
fix(signals): Revert freezing from migration docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerhahnekamp committed Jan 28, 2025
1 parent 26bb6f3 commit b00df35
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions projects/ngrx.io/content/guide/migration/v19.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,6 @@ Version 19 has the minimum version requirements:

### Signals

#### Throw error in dev mode on state mutation

The `patchState` method applies a deep freeze on the state in dev mode.
If you try to update the state directly, it will throw an error in dev mode.

BEFORE:

```ts
const userState = signalState(initialState);
patchState(userState, (state) => {
// mutable change which went through
state.user.firstName = 'mutable change';
return state;
});
```

AFTER:

```ts
const userState = signalState(initialState);
patchState(userState, (state) => {
// mutable change throws in dev mode
state.user.firstName = 'mutable change';
return state;
});
```

To fix the error, update the state in an immutable way.

```ts
const userState = signalState(initialState);
patchState(userState, (state) => {
return {
...state,
user: {
...state.user,
// immutable change which went through
firstName: 'immutable change',
},
};
});
```

#### `computed` is replaced with `props`

To support more cases, the `props` property is added to `signalStoreFeature`, which replaces the existing `computed` property.
Expand Down

0 comments on commit b00df35

Please sign in to comment.