Relative Content

Tag Archive for reactjszustand

Zustand updating in one place but not another

I am building an application that allows users to create posts using React and Zustand. Inside this hook useGetUserPosts, I am trying to get data from my Firebase database and set “posts” equal to the data in the querySnapshot. However, it seems the setPosts function is not working properly, only in one place though. Initially inside getPosts, I set posts to an empty array and that worked, but then in the try block, I tried to set it equal to the data, it doesn’t update the state here.

Zustand and Global Access: What’s Wrong Here?

I’ve done a lot of searching, and have even tried copying examples I’ve seen around the Internet, but I’m either misunderstanding, missing information, or just plain doing it wrong when trying to use the “global access” promise of Zustand.