constobj={a:10,b:15,child:{c:10,d:11}};const{a,b}=obj;// this will create 2 variables a and b with the value from object.a object.bconst{a:foo,b:bar}=obj;// this will create 2 variables foo which is a, and bar which is b. This is actually for renaming the variables so you don't have conflicts in case you have the same defined beforeconst{a,child:{c}}=obj;// It can work on nested objects too, in this case you get a and c variables
So actually it can be used on function parameters as well
constobj={a:10,b:15,child:{c:10,d:11}};constfn=param=>console.log(param.a,param.child.c);//param can be deconstructed constfn=({a,child:{c})=>console.log(a,c);
Why do you use different state objects for each input?
This part of your code
Can be simplified to this
Your right, my code isn't the best. Thank you for sharing how you would do it! I've near seen someone do this before. Pretty cool
This is a feature of ES6, called destructuring.
So actually it can be used on function parameters as well
There is more to this than the examples above.
Documentation -> developer.mozilla.org/en-US/docs/W...