platform icon indicating copy to clipboard operation
platform copied to clipboard

ComponentStore: updater() Read docs seems off.

Open TomieAi opened this issue 8 months ago • 1 comments

Information

Docs says I should write it like this.. but This doesn't seem to work properly.

readonly addMovie = this.updater((state, movie: Movie) => ({
  movies: [...state.movies, movie],
}));

It only works when I write it like this, and I just want to confirm whether I'm doing it right or wrong:

readonly addMovie = this.updater((state, movie: Movie) => ({
  ...state, 
  movies: [...state.movies, movie],
}));

sorry for bnothering...

Documentation page

https://ngrx.io/guide/component-store/write

I would be willing to submit a PR to fix this issue

  • [ ] Yes
  • [x] No

TomieAi avatar Jun 15 '25 05:06 TomieAi

What's the error that you're experiencing? The example should be fine because the state only consists of the movies property.

timdeschryver avatar Jun 16 '25 08:06 timdeschryver