V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
aqtata

jotai 的 atom 怎么调用自身?

  •  
  •   aqtata · Feb 2, 2023 · 925 views
    This topic created in 1190 days ago, the information mentioned may be changed or developed.

    定义的 atom 大概是这样子

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

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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5811 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 02:41 · PVG 10:41 · LAX 19:41 · JFK 22:41
    ♥ Do have faith in what you're doing.