ListView grid in React Native

后端 未结 9 1989
长发绾君心
长发绾君心 2020-11-28 02:18

I\'m building a simple app in React Native that fetches listings from a remote JSON source and displays them on screen.

So far, using the excellent example here, I\

9条回答
  •  执念已碎
    2020-11-28 02:48

    Check the following example using FlatList component of React Native to support infinite scrolling with an excellent performance:

    //Resize the grid
    onLayout = (event) => { 
      const {width} = event.nativeEvent.layout;
      const itemWidth = 150
      const numColumns = Math.floor(width/itemWidth)
      this.setState({ numColumns: numColumns })
    }
    
    render() {
      return (
        
            index}
            key={this.state.numColumns}
            numColumns={this.state.numColumns}
            renderItem={({item}) => 
              
            }
         />
       
      )
    }    
    

    The example looks like

    Best regards, Nicholls

提交回复
热议问题