When building responsive web applications, it's essential to be able to track changes to the screen size. This is important because different screen sizes may require different layouts, styles, or even components. One way to track changes to the screen size is to use the window object's resize event. Whenever the window size changes, the resize event is fired, allowing us to update the layout, styles, or components as necessary. In this article, we'll show you how to create an advanced React hook that tracks changes to the screen size using the resize event. Creating the useScreenSize Hook The useScreenSize hook is a custom React hook that uses the useState, useEffect, and useCallback hooks to track changes to the screen size. Here's the code for the useScreenSize hook: -------------------------------- -------------------------------- import { useState, useEffect, useCallback } from 'react'; function useScreenSize() { const [screenSize, setScreenSize] ...
In this FREE training, let's build an Evernote Clone from scratch using MONGO, EXPRESS, REACT, NODE (MERN Stack). We will be using React Hooks like useEffect, useReducer, useContext, useState and more. For the backend, we will use Nodejs/Express to create our API We will be storing our notes in Mongo. Part 1: HTML/CSS Part 2: NODE/MONGO Part 3: REACT