This repository contains my notes and code practices when learning React
The notes and code are organized in multiple branches where every branch represents a stage of learning period.
For example, the branch stage-one holds all notes and code practices for the first stage of learning period.
You can switch branches via the branch dropdown above the directory explorer.
Learn about state, component, basic hooks - useState(), useEffect().
Understand Life Cycle and Render mechanism
Learn about Conditional Content(validation) and styling the components(CSS Module)
Learn about Fragments, Portals, useRef() Hook
More about useEffect, useReducer
Optimization Techniques - useMemo, useCallback
** Understand how React works
*** React.memo()
React.memo is a higher order component. (a higher-order component is a function that takes a component and returns a new component.)
React.memo only checks for prop changes.
React.memo prevents a component from re-rendering if the props (or values within it) have not changed.
function MyComponent = (props) => {
...
}
export default React.memo(MyComponent);
However, the component will re-render again when it accepts a function as its props. Since it's a new function generated with every execution.
Thus, introducint useCallback()
*** useCallback()
useCallback stores functions, so it can be re-used when the component is executed.
function MyComponent = (props) => {
...
const addItemHandler = useCallback(
() => {
...
}, [] // dependency rule is as same as useEffect()
);
export default MyComponent;
*** useMemo()
useMemo stores any data, rarely use though.
This optimization helps to avoid expensive calculations on every render.
Sending HTTP Requests
Building Custom React Hooks
Working with more complex formm and validation
A more complex Food Order app
To run my code, navigate into a specific code practice folder via the cd command in your command prompt or terminal first.
Then run npm install to install all required dependencies (this will create a /node_modules folder).
Last, run npm start
