There are other frameworks like angular, ember etc or even Rails which have similarities / differences
We do not have a pipeline, we don't use any transpilers... yet!
Just plain and simple react
This is not how we would build a large app... why? Because we like lots of files and organisation
Build tools are out of scope
React uses camel case for props so that it can bind HTML properties if we need to
for example class="" cannot accept a dynamic value. className={} can.
JSX is not the only templating tool for react - we could use handlebars for example
The above examples are functionally the same
In new versions of React we shouldn's use classes, there is no need. React considers classes to be outdated and with the introduction of hooks, functional components can use state. React docs here https://beta.reactjs.org/reference/react/Component
We can use the browser console to view Type erros easily and it will also be highlighted in tests
We can also use Typescript which removes the need for PropTypes. Type handling is managed at compilation time not run time.
We can also use <div> instead of <React.Fragment> if we want to wrap our elements in a container. React.Fragment will not render any unneccessary wrapping element in the DOM if we don't need it. This can help with certain types of styling which targets :children for example.
The wrapping element or component is necessary as each React component render must have one root element or component
All event handlers take an event as an argument, we used it to wrap the functionality we want to perform. We can also define these inline.
Note the missing `(event)` from the onClick assignment
We haven’t talked about hooks yet - this is slightly more advanced but we can touch on it here
You cannot modify state this way in a functional component you can only use hooks which avoid this problem, note in the console when we try to modify state directly
Look at the difference between the original HelloWorldComponent and the newer HelloWorldComponent which uses the InputComponent. Note how the state is being "lifted up" a level from the input.
What do we mean by stable? indexes are bad, they can change if items are reordered. Ids are good, they are fixed and unique. You can use whatever you like as long as you can ensure it is stable and unchanging but generally indexes are not the best way.
It is possible to use indexes in a fix but not for items that may reorder. See https://robinpokorny.com/blog/index-as-a-key-is-an-anti-pattern/