https://tools.w3cub.com/vue-to-react
created: ‘componentWillMount‘,
mounted: ‘componentDidMount‘,
updated: ‘componentDidUpdate‘,
beforeDestroy: ‘componentWillUnmount‘,
errorCaptured: ‘componentDidCatch‘,
render: ‘render‘
react 没有 computed, 需要支持 手动 setState
hooks 下如何还原 setState 类似的操作:
可以使用 useReducer
const [state, setState] = useReducer(
(state, action) => {
return {
...state,
...action
};
},{ name: ‘小熊猫‘,category: ‘小熊猫科‘ })
setState({ name: ‘金鱼‘ })
原文:https://blog.51cto.com/xp114/2429447