Eduard
Eduard

Reputation: 9185

Should I pass data between components using React-Navigation or Redux?

Let's imagine I have an app with a MoviesList component consisting of SectionList of movies' names and onPress of each item in the list, I get redirected to the MovieDetails page with all the relevant data about that movie.

StackNavigator({
    list: { screen: MoviesList },
    details: { screen: MoviesDetails },
})

Could I pass the object, consisting this relevant data from the SectionList component to the MovieDetails component using params of React-Navigation or it's better, from the performance point of view, to handle this in a Redux?

Upvotes: 0

Views: 115

Answers (1)

vonovak
vonovak

Reputation: 1597

You'll have to pass something to the MoviesDetails screen.

It may be an id, that you'll use on the screen to get a movie object from redux, or you may as well pass the entire object to MoviesDetails, which will very likely be more convenient from developer point of view.

Performance-wise, this will make no difference, but you may want to consider deep linking (say somebody opens the app via a browser and in that case, all your screen gets is some movie id).

Upvotes: 1

Related Questions