Rahul Bansal has Published 50 Articles

ReactJS – useReducer hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:58:54

575 Views

This hook is a better alternative of the useState hook, as it is used when we want to attach a function along with handling the state or when we want to handle the state based on the previous values.Syntaxconst [state, dispatch] = useReducer(reducer, initialArgs, init);ParametersReducer − The function to handle ... Read More

ReactJS – useMemo hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:55:25

612 Views

In this article, we are going to see how to optimize a React application by passing a memoized value.This hook is used to optimize the React application by returning a memoized value which helps to prevent doing the complex calculations on every re-rendering. This hook stores the cached value and ... Read More

ReactJS – useLayoutEffect hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:52:31

288 Views

In this article, we are going to see how to set up side-effects or HTTP requests in a functional component.This hook has the similar functioning like that of useEffect hooks but rather than being called out asynchronously, it has a synchronous effect. This hook is used to load the data ... Read More

ReactJS – useImperativeHandle hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:50:36

753 Views

In this article, we are going to see how to customize the instance value of the ref object.Both useImperativeHandle and useRef hook allows to pass the ref object but the latter one doesn’t allow to customize the instances that are also passed with the ref object. useImperativeHandle hooks is different ... Read More

ReactJS – useEffect hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:47:57

609 Views

In this article, we are going to see how to set up side-effects or HTTP requests in a functional component.This hook is used to set up subscriptions, handle side-effects or to send analytics data to the server. It is the combination of componentDidMount, componentDidUpdate and componentWillUnmount methods of class-based components. ... Read More

ReactJS – useDebugValue hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:47:33

205 Views

In this article, we are going to see how to debug the custom hooks with the useDebugValue hook in ReactJS.This hook provides custom labels to custom hooks so as to make the process of debugging easier and efficient. It is only called when the React Developer tools are toggled on.SyntaxuseDebugValue(value, ... Read More

ReactJS – useContext hook

Rahul Bansal

Rahul Bansal

Updated on 19-Mar-2021 10:46:59

548 Views

In this article, we are going to see how to access the data without passing it through every parent component in the React Lifecycle.This hook is the better replacement of the Context API of the Class-based component which is used to set the global data and this data can now ... Read More

ReactJS – useCallback hook

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 12:04:38

960 Views

In this article, we are going to see how to optimize a React application by passing a memoized function.This hook is used to optimize a React application by returning a memoized function which helps to prevent unnecessary re-rendering of a function. This hook stores the cached value of the function ... Read More

ReactJS – shouldComponentUpdate() method

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 12:01:54

2K+ Views

In this article, we are going to see how to increase the performance of React application by rerendering the component only when the props passed to it changes or on when certain conditions are met.This method is majorly used to take an exit from the complex React lifecycle, but using ... Read More

ReactJS – getSnapshotBeforeUpdate() Method

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:58:57

872 Views

In this article, we are going to see how to execute a function after the component is updated and before rendering it to the DOM.This method is called before the rendering of the component and after it is updated. This method is majorly used to compare the previous state or ... Read More

Advertisements