dvajs / dva

🌱 React and redux based, lightweight and elm-style framework. (Inspired by elm and choo)
https://dvajs.com/
MIT License
16.24k stars 3.17k forks source link

DVA 怎么使用 react 的生命周期函数?例如 componentdidmount, componentDidShow 之类的? #2419

Closed 946629031 closed 3 years ago

946629031 commented 3 years ago

DVA 怎么使用 react 的生命周期函数?例如 componentdidmount, componentDidShow 之类的?

我现在需要 监听页面的 onShow 事件,也就是 componentDidShow 生命周期函数,

每次当页面重新被显示的时候,我要 初始化一个值,如 activeKey = '1' 。 这种情况 我在dva中,应该如何实现??

caidongwei commented 3 years ago

使用react hook 的useEffect来模拟react生命周期 useEffect(() => { console.log('模拟componentDidMount以及componentDidUpdate'); return () => { console.log('模拟componentWillUnmount'); } })

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.