V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
aqtata
V2EX  ›  前端开发

jotai 的 atom 怎么调用自身?

  •  
  •   aqtata · 2023-02-02 10:42:09 +08:00 · 494 次点击
    这是一个创建于 510 天前的主题,其中的信息可能已经有所发展或是发生改变。

    定义的 atom 大概是这样子

    export const startTaskAtom = atom(null, async (get, set) => {
        console.log('startTaskAtom');
        // some code
        if (condition) {
            set(startTaskAtom);
        }
    }
    

    我期望在条件达成时调用自身,像上面那样用set去调用虽然没有报错,但也没有执行。 还是说这样的思路是错的?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1243 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:04 · PVG 02:04 · LAX 11:04 · JFK 14:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.