Two questions:
- Why
mapStateToProps
is called before constructor? As a side-effect of 1
constructor (props) { base(props) // props already have values from "mapStateToTprops" }
why that is being done automagically?
- Not every
mapStateToProps
invokesComponentWillReceiveProps
(this is the case when it loads first time) See this link enter link description here
Update 1
If I want to write a condition like:
if (props.isAuthenticated) {
browserHistory.push("/admin/dashboard")
}
Which method will be most suitable to hook. Keep in mind that I want to enforce this condition on each state change (because according to leo's answer ComponentWillReceiveProps is not reliable)?