V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thefack
V2EX  ›  问与答

对 React use-between 的例子有个疑问,望解答

  •  
  •   thefack · 2022-04-16 21:10:31 +08:00 · 299 次点击
    这是一个创建于 907 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://github.com/betula/use-between

    给的例子中,为什么要用useSharedCounter多包装一次useCounter

    const useSharedCounter = () => useBetween(useCounter);

    我试了下,将上面一句省掉,直接用 const { count } = useBetween(useCounter);也能使用啊。

    有什么特殊场合需要那样吗?

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