Advanced React Tutorials Playlist by techsith
(See commit 1)
Fragment elements basically are like divs except that they only stay in JSX, they don't render to HTML (invisible).
note: "react hooks" have a completely different way to handle lifecycle matters.
The current lifecycle methods for React 16.4+ are...
There are two renders: the initial render and the rerender.
initial render lifecycle:
-> constructor
-> static getDerivedStateFromProps (static prevents you from setting state; this method is rarely used)
-> render (can't set state here either)
-> componentDidMount
rerender lifecycle:
-> static getDerivedStateFromProps
-> shouldComponentUpdate
-> render
-> getSnapshotBeforeUpdate
-> componentDidUpdate
arrows functions allow us to set state in React.
Also it allows us to not call a method right away on click.
3 ways.
-> shouldComponentUpdate()
-> extend React.PureComponent (for "class" components)
-> React.meme (for "functional/presentational" components)
static getDerivedStateFromError. componentDidCatch. Helps catch errors if a component is not going to render
componentDidMount, when the component is completely rendered. make sures that your DOM is ready.
Context API pattern (use it when we pass props into a deeply nested component, with this pattern you access props via context API; you wrap your component with a special tag, provider and consumer component, provider accepts the props, and consumer is anywhere you want to use those props).
Render props: instead of passing a component as a component, you pass it as a function.
Presentation component pattern. I
The decision has to be made based on the project itself. If React is planning a huge update within the year, don't use it. If your developers are Javascript saavy, use Javascript.
Because React uses all JS, you can pass CSS as all JS objects.
setState will trigger a rerender.
If statement, and statement, conditional operator.
You can render multiple children. When you wrap the children in a div it creates too many tags which creates errors with the CSS.
If you have a large project, you might not want to import everything at once. For this, React introduced dynamic import and lady loading.
mobX, apollo client + graphQL, RxJS
First sends the post request that goes to the server, and when a positive response is coming back, update the local store.
These are both middleware. I don't use these two technologies currently.