浅谈connect,withRouter,history,useState,useEffect

1、connect in umi
connect 可以链接不同的组件,从而在这个组件中使用其他组件的参数,常用于获取redux中存取的值。
2、withRouter in umi
withRouter 通过withRouter可以轻松拿到当前页面的location,而location中的pathname和query属性常常跟查询有关,一般这个东西用在需要查询的组件中例如列表
3、history in umi
history 常用语路由跳转history.push(path),也可和redux结合用作查询,history.replace(path)
4、useState in react
useState 用于函数组件 Hooks 等价于等价于class组件 state,setState
5、useEffect in react
useEffect Hooks 我的理解是相当于conponentWillMount,此函数附带参数,当写了参数之后,每次参数变化将会执行一次,他的执行应该是在页面加载之前,通常与useState使用,读取redux传过来的值,监听该值的变化,通过setState实时渲染页面数据

  

原文地址:https://www.cnblogs.com/iwen1992/p/13932176.html