vue 转react尝试
今天学习了一下react,感觉跟vue 语法类似。于是举一反三搜索了一下,发现由个工具,可以提供这样子的服务:
https://tools.w3cub.com/vue-to-react
vue 和 react 的生命周期created: 'componentWillMount',mounted: 'componentDidMount',updated: 'componentDidUpdate',beforeDestroy: 'componentWillUnmount',errorCaptured: 'componentDidCatch',render: 'render'
react 没有 computeds
react 没有 computed, 需要支持 手动 setState
hooks 语法hooks 下如何还原 setState 类似的操作:
可以使用 useReducer
const [state, setState] = useReducer( (state, action) => { return { ...state, ...action }; },{ name: '小熊猫',category: '小熊猫科' })
setState({ name: '金鱼' })
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。