From 626a9758e358d2bc32c8cbf1d43a6bbe61710c5e Mon Sep 17 00:00:00 2001 From: asabeneh Date: Tue, 13 Oct 2020 07:15:13 +0300 Subject: [PATCH] polishing --- 12_Day_Forms/12_forms.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/12_Day_Forms/12_forms.md b/12_Day_Forms/12_forms.md index ffa2280e58..6bf6a2cf5f 100644 --- a/12_Day_Forms/12_forms.md +++ b/12_Day_Forms/12_forms.md @@ -148,18 +148,30 @@ class App extends Component { } handleChange = (e) => { /* - // we can get the name and value like this but we can also destructure it from e.target + we can get the name and value like this: e.target.name, e.target.value + but we can also destructure name and value from e.target const name = e.target.name const value = e.target.value */ const { name, value } = e.target - // [variablename] this we can make a value stored in a certain variable could be a key for an object, in this case a key for the state + // [variablename] to use a variable name as a key in an object + // name refers to the name attribute of the input elements this.setState({ [name]: value }) } handleSubmit = (e) => { - // stops the default behavior of form element specifically refreshing of page + + /* + e.preventDefault() + stops the default behavior of form element + specifically refreshing of page + */ e.preventDefault() - // the is the place where we connect backend api to send the data to the database + + /* + the is the place where we connect backend api + to send the data to the database + */ + console.log(this.state) }