Skip to content

Commit

Permalink
docs: clarify action merging behavior when combining slices (#30)
Browse files Browse the repository at this point in the history
When I tried the code myself, I wasn't expecting the actions to be merged and thought it was a mistake. It was concluded, in another discusstion, similar confusion might arise when others try it too.
  • Loading branch information
unbeauvoyage authored Sep 27, 2024
1 parent 41a73f6 commit 07b8fe7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/getting-started/01_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ By utilizing `create` from Zustand, you can combine these slices into a single s
const useCountStore = create(withSlices(countSlice, textSlice));
```

> 💡 **Note:** Actions with the same name across slices are merged into a single action in the combined store. Calling such an action executes the corresponding actions from each slice. For example, since both slices have a `reset` action, calling `reset` will reset both `count` and `text` to their initial values.
### Easily utilize it in your components

Finally, you can seamlessly integrate and access your store directly into your component logic utilizing the `useCountStore` hook.
Expand Down

0 comments on commit 07b8fe7

Please sign in to comment.