0

I having problem when I push to next screen.

Lets say from screen A(product details screen) -> screen B(product details screen)

Currently I am successfully move from screen A to screen B. But the problems is when i navigate back to screen A, the data in screen A already updated which is same as screen B.

Below is how i update my screen data by using componentDidMount() and navigate to next screen using push.

componentDidMount() { 
    this.props.getDetails(id);
}
this.props.navigator.push({
    screen:'myapp.productDetailsScreen'
})

Is it something i missed that accidentally update screen a data when i navigate to screen b?

Screen A and Screen B share the same component (they just render different value based on the id given).

I am using this library

react-native-navigation v1 (wix)

Any help is appreciated! Thanks.

1 Answers1

0

if you are using redux you the redux state between both of the screens is shared. that is why it is updated on both screens.

gamingumar
  • 979
  • 8
  • 14
  • then how am i suppose to do like that ? (I am using redux) Any recommend idea will be appreciated!! – loveCodeloveYou Nov 12 '18 at 01:14
  • what you can do is don't put this response in redux at all. you can return data directly from redux, or create a new data structure to handle all the items in it. maybe an array.. – gamingumar Nov 12 '18 at 11:56
  • Thank you so much for making me become more clearer about how those data flow between component and redux! Really appreciated your help!! – loveCodeloveYou Nov 16 '18 at 02:56