FlatList renderItem is called multiple times

前端 未结 2 1383
梦谈多话
梦谈多话 2020-11-30 15:23

I\'m using FlatList to display data from an API call:

render() {
  const { navigation } = this.props;
  const animating = this.state.animating;

  return (
          


        
2条回答
  •  孤街浪徒
    2020-11-30 16:29

    https://snack.expo.io/B1KoX-EUN - For optimization and prevent re-render you can call shouldComponentUpdate(nextProps, nextState) to diff this.state or this.props and return true/false - https://reactjs.org/docs/react-component.html#shouldcomponentupdate docs say this callback should be used only for optimization which is what we're doing here.

提交回复
热议问题