cookygg 最近的时间轴更新
cookygg

cookygg

V2EX 第 498938 号会员,加入于 2020-07-13 15:23:44 +08:00
今日活跃度排名 7466
cookygg 最近回复了
11 天前
回复了 devzhaoyou 创建的主题 React React hook 使用疑惑
const [count, setCount] = useState(0);

const [,update] = useState({})

const fetch = () => {
fetchMoreData(count)
};

useEffect(() => {
fetch();
}, [count]);

const handleClick = () => {
// count 的值之前就是 0 ,上面的 useEffect 不触发
setCount(0);

// 手动更新 也算一个解决
update({})
};
支持一下
test & mark
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3558 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 04:32 · PVG 12:32 · LAX 21:32 · JFK 00:32
Developed with CodeLauncher
♥ Do have faith in what you're doing.