Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redux dispatch or react-navigation for passing params?

Is it better to pass params from one screen to another with redux dispatch or with react-navigation ?

Redux way:

Passing params (screen 1)

dispatch({
  type: PARAMS_TYPE,
  payload: {param1, param2}
});

Getting params (screen 2)

const {params} = this.props;

React-navigation way:

Passing params (screen 1)

this.props.navigation.navigate("Screen2",{param1, param2});

Getting params (screen 2)

this.props.navigation.state.params.param1;
like image 366
unijob Avatar asked Sep 16 '25 09:09

unijob


1 Answers

If you are using Redux in your Application than better way to do this is through Redux. This is because Redux stores complete state of an application in a single store which you can access from any component using props. React-navigation will make this task very complex and difficult to maintain if the Application is complex.

like image 170
Akshay Darji Avatar answered Sep 18 '25 09:09

Akshay Darji