react-native-grid-view icon indicating copy to clipboard operation
react-native-grid-view copied to clipboard

Navigating from each item in the GridView

Open hrishikeshsoman opened this issue 8 years ago • 1 comments

Hi,

I am trying to use GridView to list some movies in my project. Each movie item in the GridView is supposed to take the application to a movie detail page. I was trying to accomplish this using the Navigator component. Please find the code snippet here:

  renderScene = (route, navigator) => {
    switch (route.name) {
      case 'List':
        return (<GridView
          items={data.result}
          itemsPerRow={MOVIES_PER_ROW}
          renderItem={this.renderItem}
          style={styles.listView}
        />);
renderItem = (item) => {
   return <Movie movie={item} onPress={this.bookClicked} />
 }

I would like to pass a 'navigator' object to my Movie component from the switch statement. I am facing trouble in doing that. Any suggestions would be appreciated.

hrishikeshsoman avatar Feb 13 '17 12:02 hrishikeshsoman

renderItem = (item, columnNumber) => {
   return renderMovie(item, columnNumber, navigator);
}

renderIMovie = (item, columnNumber, navigator) => {
   return <Movie movie={item} onPress={this.bookClicked} navigator=navigator />
 }

mark0978 avatar Apr 01 '17 05:04 mark0978