Why did the react only use componentDidMount () to get the data? render executed it for me four times.

@connect(({ editnews,global, loading }) => ({
  global,
  editnews,
  loading: loading.models.editnews,
  timeLoading: loading.effects["editnews/getCollections"],
}))
componentDidMount() {
    message.warning(",",10)
    const { dispatch} = this.props;
    dispatch({
      type: "editnews/getCollections",
      payload: {}
    });
  }
render() {
    const {
      editnews: { data, data: { pagination }, collections },
      loading,
      timeLoading,
    } = this.props;
    console.log(pagination)

clipboard.png

Jun.23,2022

in a component state or props changes will execute the render method, probably because your other data has changed.
if you don't want to implement the render method, you can judge it in the shouldComponentUpdate method. return false can block render , which is also the solution recommended by react officially.


before looking for this problem, familiarize yourself with the lifecycle function of react. For example, you can take a look at this article ider" rel=" nofollow noreferrer "> http://kuaibao.qq.com/s/20190.... After reading it, print these two values in the lifecycle that receives state props changes, and you will find that they are changing all the time

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c343-2c322.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c343-2c322.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?