Context API is a way of passing props or data to every level of the component tree without doing the props drilling. It reduces the complexity of passing props to every single component until it reaches its destination component. With the help of context API now we can pass data through all the components and the destination component can easily receive this data using a hook called useContext.
export const ContextName = createContext(default value);
<ContextName.Provider value=” ”><Component1 /><Component2 /><Component3 /><ContextName>
<ContextName.Provider value=” any valid JS value ”>
export const ContextName = createContext(default value);
Custom hooks are those hooks that are made by use not by React. When we have some common lines of code that need to be used by multiple components, then instead of writing the same code in every component we can extract those codes and make a custom hook. And replace those codes with our custom-made code.
useRef is a React hook that creates a mutable variable which not re-render the component on every change. useRef returns a ref object with a single property initially set to the initial value we provided. On the next renders, useRef will return the same object. If we change a ref it does not trigger a re-render. That’s why it is perfect for storing information that doesn’t affect the visual output of our component.
Syntax:
const ref = useRef ( initialValue )
useMemo is a React hook that memorized the result of a calculation between re-renders. It is used to increase the performance of a React app. If there is an expensive task on the website this hook will memorize the expensive task and only use that expensive task when needed instead of using it on every re-render.
Syntax:
const variableName = useMemo( calculate value that needed to memorized, dependencies )
There are many variations of passages of
Lorem Ipsum , but the majority have suffered
alteration in some form.
About Us
Work
Latest News
Careers
Prototype
Plans & Pricing
Customers
Integrations
Help Desk
Sales
Become a Partner
Developers
524 Broadway , NYC
+1 777 - 978 - 5570
@2023 Rocket-Jobs. All Rights Reserved
Powered by Rocket-jobs