You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Zustand与NextJS时遭遇“Cannot access 'createResettable' before initialization”初始化前访问错误的求助

使用Zustand与NextJS时遭遇“Cannot access 'createResettable' before initialization”初始化前访问错误的求助

我在Zustand和NextJS里写了几个简单的组件,不知道为啥突然碰到这个错误:Cannot access 'createResettable' before initialization。我明明已经定义了createResettable函数,而且导入路径也反复确认过是对的啊,实在搞不懂问题出在哪……

下面是我的./quoteStore.ts代码片段:

import { createResettable } from "../_hooks/hooks"; // 已经确认导入路径正确
import { type Customer } from "./types";

type QuoteStore = {
  id: string | null;
  date: string | null;
  customer: Customer | null;
  subTotal: string;
  tax: string;
  total: string;
  taxRate: number;

  //Setters
  setCustomer: (customer: Customer | null) => void;
  setQuoteDefaults: (
    input: Pick<
      QuoteStore,
      "id" | "date" | "customer" | "subTotal" | "tax" | "total" | "taxRate"
    >,
  ) => void;
  setTotals: (subTotal: string, tax: string, total: string) => ...;
};

备注:内容来源于stack exchange,提问作者mogcast

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 12:50:31