Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why separate methods for mapDispatchToProps and mapStateToProps?

Tags:

redux

I'm writing a redux app and I ran in to a small but nagging question. Why is the convention to separate the mapDispatchToProps and mapStateToProps methods? Why not just have one:

mapToProps = (state, dispatch) => {
    ...
}
like image 677
swelet Avatar asked Feb 17 '16 17:02

swelet


1 Answers

Because the mapDispatchToProps doesn't need to be recompiled when the state change (it's only called once).

like image 174
Simon Boudrias Avatar answered Sep 28 '22 10:09

Simon Boudrias