From 2565d4c44a2a4b863f0b2333af1c28f19098477b Mon Sep 17 00:00:00 2001 From: "Ina S.Lew" Date: Fri, 29 Mar 2019 16:20:11 +0100 Subject: [PATCH] Commented full solution (#35620) * Include a default case for messageReducer * Commented full solution --- .../extract-local-state-into-redux/index.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/guide/english/certifications/front-end-libraries/react-and-redux/extract-local-state-into-redux/index.md b/guide/english/certifications/front-end-libraries/react-and-redux/extract-local-state-into-redux/index.md index 36094b84fe..8c27802ab3 100644 --- a/guide/english/certifications/front-end-libraries/react-and-redux/extract-local-state-into-redux/index.md +++ b/guide/english/certifications/front-end-libraries/react-and-redux/extract-local-state-into-redux/index.md @@ -53,6 +53,8 @@ const connect = ReactRedux.connect; class Presentational extends React.Component { constructor(props) { super(props); + + // Remove property 'messages' from Presentational's local state this.state = { input: '' } @@ -65,11 +67,13 @@ class Presentational extends React.Component { }); } submitMessage() { - this.props.submitNewMessage(this.state.input); - this.setState({ - input: '' - }); - + + // Call 'submitNewMessage', which has been mapped to Presentational's props, with a new message; + // meanwhile, remove the 'messages' property from the object returned by this.setState(). + this.props.submitNewMessage(this.state.input); + this.setState({ + input: '' + }); } render() { return ( @@ -80,6 +84,9 @@ class Presentational extends React.Component { onChange={this.handleChange}/>