Skip to content

Slices patterns, access multiple slices: data cannot be accessed #2045

Answered by dbritto-dev
norama asked this question in Bug report
Discussion options

You must be logged in to vote

@norama you are trying to create actions base on create slice functions which is wrong, that's why you always get the default values. You should always use get() to access to any function or prop/field.

Here you go

const createResetAllSlice = (set, get) => ({
  resetAll: () => {
    get().resetApples();
    get().resetPears();
  },
  sum: () => get().apples + get().pears
});

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@dbritto-dev
Comment options

Comment options

You must be logged in to vote
5 replies
@norama
Comment options

@dbritto-dev
Comment options

@dbritto-dev
Comment options

@dbritto-dev
Comment options

@norama
Comment options

Answer selected by norama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2044 on September 11, 2023 10:56.