useState 钩子和 useReactiveVar反应变量钩子有什么区别?

问题描述

下面两段代码基本上有什么区别?我们可以说 useReactiveVar 是一种具有重新渲染能力的 useRef 吗?

  1. useState(此日志会记录“iAmAwesome”吗?)
const [awesomeVar,setAwesomeVar] = useState("iAmAwesome");
setTimeout(() => console.log(awesomeVar),1000);
setAwesomeVar("youAreAwesome");
  1. useReactiveVar(此日志会记录“iAmAwesome youAwesome”吗?)
const reactiveVar = makeVar("iAmAwesome");
// ...
const awesomeVar = useReactiveVar(reactiveVar);
setTimeout(() => console.log(awesomeVar,useReactiveVar()),1000);
useReactiveVar("youAreAwesome");

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)