Skip to content

Bugfix/state.age is not defined when mapping state to props app.js line: 19#5

Open
Rajesh-Royal wants to merge 2 commits intotechsithgit:masterfrom
Rajesh-Royal:bugfix/state.age-is-not-defined
Open

Bugfix/state.age is not defined when mapping state to props app.js line: 19#5
Rajesh-Royal wants to merge 2 commits intotechsithgit:masterfrom
Rajesh-Royal:bugfix/state.age-is-not-defined

Conversation

@Rajesh-Royal
Copy link

Your code through runtime error that state.age is not defined.
To solve this when you mapStateToProps you could have passed some default value to the state.

here: -------

const mapStateToProps = (state = {age: 21}) => { 
return { age: state.age } 
};

Error stage Image:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant