Classes and the Extend keyword: Worth mentioning that nowadays you don't need classes for components in React (Error boundaries are the only exception, and you can still use npm dependencies to not use classes for that either).
Async/Await: Before learning async/await is key folks understand Promises. An example of that getPersonsInfo function without async/await to illustrate:
Is also important to notice that using async functions in side effects with useEffect is far from ideal.
Array methods: Important resource when working with React: doesitmutate.xyz/ ... that site shows which methods change the original data and which ones don't. You should try to avoid mutations in React, so stay away from the methods that change the original data.
Template Literal: They are way more powerful than plain strings, because they also provide a way of using a function next to them. More info here. I use that approach in one of my libs.
Deconstructing: Deconstructing is quite convinient in function components, and can be done directly on the head of the function:
constGreeting=({name})=><div>hello {name}</div>;
And also is worth mentioning that you can set default values for optional properties:
Also, your example has a typo when deconstructing objects.
Spread Operator: To concat arrays, nowadays is still faster to use Array.prototype.concat, but for stuff like copying object properties is actually really convenient.
Import and Export: In the export example you're missing the export keyword. And is also important to mention that you can import and export named and default, so ideally we should have 4 examples.
Code Hello World project with React: You mention a link to download Node, but didn't provided it. Also the command to run create-react-app is actually:
npm init react-app
And the default app is already a "hello world" of sorts, so idk if this point makes much sense.
A few missing things I noticed where missing or incomplete:
returnkeyword always, so you can write thatsubtractfunction like this:And
Applike this:Classes and the Extend keyword: Worth mentioning that nowadays you don't need classes for components in React (Error boundaries are the only exception, and you can still use npm dependencies to not use classes for that either).
Async/Await: Before learning
async/awaitis key folks understand Promises. An example of thatgetPersonsInfofunction withoutasync/awaitto illustrate:Is also important to notice that using async functions in side effects with
useEffectis far from ideal.Array methods: Important resource when working with React: doesitmutate.xyz/ ... that site shows which methods change the original data and which ones don't. You should try to avoid mutations in React, so stay away from the methods that change the original data.
Template Literal: They are way more powerful than plain strings, because they also provide a way of using a function next to them. More info here. I use that approach in one of my libs.
Deconstructing: Deconstructing is quite convinient in function components, and can be done directly on the head of the function:
And also is worth mentioning that you can set default values for optional properties:
Also, your example has a typo when deconstructing objects.
Spread Operator: To concat arrays, nowadays is still faster to use
Array.prototype.concat, but for stuff like copying object properties is actually really convenient.Import and Export: In the export example you're missing the
exportkeyword. And is also important to mention that you can import and export named and default, so ideally we should have 4 examples.Code Hello World project with React: You mention a link to download Node, but didn't provided it. Also the command to run
create-react-appis actually:And the default app is already a "hello world" of sorts, so idk if this point makes much sense.
That's it! Cheers!
Hello @lukeshiru
Ty for reading the article.
Noted all your remarks
🚀🚀
Just PM you on Twitter.
🚀🚀
In case you have time for a small chat, thanks in advance.
Nice article. Thanks