Skip to content

The type of setState is a object when it is built and deployed to Cloudflare pages while locally it is a function. #2548

Closed Answered by KamaniBhavin
KamaniBhavin asked this question in Q&A
Discussion options

You must be logged in to vote

It turns out the issue was related to how I configured the slices. Initially, I set up the slices as a function that returned a state creator, as illustrated in the incorrect example below:


function createSliceA(): StateCreator<...> {
  return (set, get) => ({

  })
}

export function store() {
  return createStore<TStore>()(
    immer((...args) => ({
      ...createSliceA()(...args),
      ...createSliceB()(...args),
    })),
  );
}

The correct configuration involves defining the slices directly as functions, which fixed the problem. Here's the corrected code:


const createSliceA = (set, get) => ({

})

export function store() {
  return createStore<TStore>()(
    immer((...args) => ({

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by KamaniBhavin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant