[question] Is it possible to obtain the variables and methods in the ASlice through get
in the BSlice?
#2949
Answered
by
dbritto-dev
liaodalin19903
asked this question in
Q&A
-
We know that when using Zustand, multiple Slices can be configured. export const createASlice: StateCreator<ASlice> = (set, get) => ({
aState: string,
action1: () => {
},
action2: () => {
// get can obtain the variables or methods defined in this Slice
}
});
export const createBSlice: StateCreator<BSlice> = (set, get) => ({
bState: string,
action1: () => {
},
action2: () => {
// get can obtain the variables or methods defined in this Slice
}
}); Excuse me. Is it possible to obtain the variables and methods in the ASlice through |
Beta Was this translation helpful? Give feedback.
Answered by
dbritto-dev
Jan 14, 2025
Replies: 1 comment 6 replies
-
@liaodalin19903 it is possible get return the whole state instead of just slice state but the returned state should be the slice state |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@liaodalin19903 the type is wrong, should be
For
CreateASlice
For
CreateBSlice
In a nutshell
Ref: https://zustand.docs.pmnd.rs/guides/typescript#slices-pattern