From 77b4aea95ec4a43ab1918207541ad16e7e3fd196 Mon Sep 17 00:00:00 2001 From: Emin Yilmaz <70356757+unbeauvoyage@users.noreply.github.com> Date: Fri, 27 Sep 2024 21:45:17 +0900 Subject: [PATCH] docs: clarify action merging behavior when combining slices 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. --- docs/getting-started/01_introduction.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/getting-started/01_introduction.md b/docs/getting-started/01_introduction.md index 8e722df..0075e05 100644 --- a/docs/getting-started/01_introduction.md +++ b/docs/getting-started/01_introduction.md @@ -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.