当我在nextjs项目里面使用zustand,然后读了文档: https://docs.pmnd.rs/zustand/guides/nextjs
Next.js is a popular server-side rendering framework for React that presents some unique challenges for using Zustand properly. Keep in mind that Zustand store is a global variable (AKA module state) making it optional to use a Context. These challenges include:
Per-request store: A Next.js server can handle multiple requests simultaneously. This means that the store should be created per request and should not be shared across requests.
我的问题:
- 怎么还有request的事儿呢?这个不是在client side用的吗?
- 默认的store是per-request的吗?
- 啥意思啊,完全不懂。根据这个文档,用zustand在nextjs项目里面还要添加storeProvider,为啥要添加这个,我不添加这个也能正常使用zustand啊?
- 这个东西到底是为了避免什么问题啊?
我已经问了所有的AI工具,还是搞不清这个说的是情况,请高人指点。感谢!!!