2. Using Intersection Observer API The Intersection Observer API asynchronously observes the changes and loads images as the element enters the viewport. The prior approach required us to bind events, consider performance, and build a mechanism to determine if an element was in the viewport or not...
Alright, so you're all geared up to make the switch to TypeScript with your React project? Great decision! But before we dive into the actual process, we need to make sure a few things are in place. Consider this our prep stage, where we get all our tools ready so that the transiti...
React components re-render when there is a change in their state or props. However, there might be scenarios where a component receives new props but doesn’t need to re-render because the computation result remains the same. In such cases, you can use‘useMemo()’to memoize the computed ...
In this case, when passing the type for the ref param, we need to make sure we are wrapping the element type with React.Ref. Both ways to declare the component are valid, and there is no argument for one over the other. It’s up to the developer’s style, and in my case, I ...
The new Context API in React solves one major problem–prop drilling. Even if you’re not familiar with the term, if you’ve worked on a React.js app, it has probably happened to you. Prop drilling is the processing of getting data from component A to component Z by passing it through...
In this tutorial, Chidi Orji will show you how to build a React drag-and-drop component for file and image uploads. In the process, we’ll learn about the HTML drag-and-drop API. We will also learn how to use the useReducer hook for managing state in a R
Now, JavaScript has its own built-in way to make API requests. This is the Fetch API, a new standard to make server requests with Promises, but which also includes additional features. In this tutorial, you will create both GET and POST requests using the Fetch API. ...
In many React applications, you’ll send the data to an external service, like a WebAPI. When the service resolves, you’ll often show a success message, redirect the user, or do both. To simulate an API, add asetTimeoutfunction in thehandleSubmitfunction. This will create anasynchronous...
What is Redux and why you might want to use it The terminology of Redux: actions, reducers, store, dispatch, connect, and container Making asynchronous API calls with Redux Thunk How to make a small, real-world application with React and Redux How to use Redux Toolkit to simplify Redux app...
The first feedback we got is that people were having trouble with having to use async/await. In this approach, it is unavoidable. Message-passing is fundamentally an asynchronous operation, and there’s no way in JavaScript to make a synchronous, blocking call to an asynchronous operation. At...