Found 127 Articles for ReactJS

How to pass multiple props in a single event handler in ReactJS?

Raju Dandigam
Updated on 14-Apr-2025 11:28:50

22 Views

Passing multiple props in a single event handler in ReactJS can be useful for situations where more than one value needs to be worked on based on some user input. In this article, we will discuss three different ways to pass props in a single event handler in ReactJS. Here is a list of approaches: Using Arrow Functions Using bind() Method Using Event Object Using Arrow Functions To pass multiple props in a single event handler, we will use the most popular approach i.e. ... Read More

Redux Thunk vs. Redux Saga: Choosing the Right Middleware

Harleen Kaur
Updated on 22-Jan-2025 11:01:55

1K+ Views

Redux Thunk and Redux Saga are two famous middleware picks for controlling negative consequences in Redux packages. Although they use their own different techniques, each technology assist with asynchronous duties like API requests. Redux Saga offers an improved and flexible solution for complicated duties, whereas Redux Thunk is simpler to use and is more basic. This article will help you to decide that which one is suitable as per your needs by examining their features and differences. Redux Thunk You can create action creators that return a function rather than an action object by using Redux Thunk, a Redux middleware. ... Read More

How To Copy Text To The Clipboard In ReactJS?

Rohit Kumar Dwivedi
Updated on 23-Dec-2024 09:22:29

102 Views

In this article, we will learn how to copy text to the clipboard in ReactJS. There are two most commonly used methods: the copy-to-clipboard package and the Clipboard API. The copy-to-clipboard package provides a copy() function that allows us to copy text. The Clipboard API is a web browser API that also provides a few functions for clipboard interaction, including copying text. Prerequisites Installed npm ReactJS useState hook Approaches to Copy Text to Clipboard There are two primary approaches to copying text to the clipboard in ReactJS: ... Read More

How to programmatically navigate using React Router?

Rohit Kumar Dwivedi
Updated on 20-Dec-2024 09:41:22

66 Views

In this article, we will learn how to programmatically navigate using React Router. Programmatic navigation enables changing the URL of an application without reloading the page. We can use several approaches to programmatically navigate in a React application using React Router. Approaches to navigate using React Router To programmatically navigate a React application, we can use several methods based on the version of React Router. In React Router v6, the useNavigate hook is introduced, which is recommended for programmatic navigation. By calling the navigate function returned from useNavigate, we can navigate to other routes. In React Router v5, the ... Read More

How to pass data from child component to its parent in ReactJS?

Rohit Kumar Dwivedi
Updated on 19-Dec-2024 09:35:33

99 Views

Passing data from one component to another is an essential part of building complex React applications. React props and states are fundamental concepts in React. Props stand for properties, which are used for passing data from one component to another, while State is used to manage data within a component. Prerequisites ReactJS Props ReactJS State Passing Data from Child Component to Parent You can easily pass data from a parent component to a child component with the help of props. Passing data from a child component to a ... Read More

How to Redirect to Another Page in ReactJS?

Rohit Kumar Dwivedi
Updated on 19-Dec-2024 09:38:16

150 Views

Redirecting is one of the vital features in frontend applications like React apps. Moving from one page to another is known as navigation. In React, navigation is important for maintaining a Single Page Application for a better user experience. react-router-dom is a npm package which enables dynamic routing in react application. In this article, we are going to learn how we can redirect from one page to another in ReactJS. Using React Router Dom Navigating to another page can be done efficiently with the help of react-router-dom. It is an npm package responsible for client-side navigation. Using React ... Read More

How to Fix React useEffect running twice in React 18?

Rohit Kumar Dwivedi
Updated on 17-Dec-2024 10:10:04

105 Views

In this article, we will cover why React 18's useEffect runs twice and how to handle this. If you recently switched your React application to version 18, you might have noticed that useEffect runs twice during component mounting. React 18 introduces a new development-only check called Strict Mode. This new check will automatically unmount and remount every component. Let's dive deeper into why this happens. Why useEffect runs twice? In React 18, when you are in development mode, your application runs in StrictMode by default. In StrictMode, React mounts, unmounts, and remounts components. It helps developers identify bugs and unexpected ... Read More

How to Loop inside React JSX?

Rohit Kumar Dwivedi
Updated on 17-Dec-2024 11:26:45

60 Views

In this article, we are going to learn how to iterate on list or collection of data dynamically. However, directly using a loop is not a valid syntax in JSX. It is crucial to understand how to use loops inside React JSX. By iterating on arrays or any collections of data, we can render the component dynamically. Prerequisites ReactJS JSX Approaches to Loop inside React JSX The map() function and other methods can be used to repeat elements in JSX when we need to iterate over a list ... Read More

Difference between npx and npm

Rohit Kumar Dwivedi
Updated on 17-Dec-2024 10:21:57

58 Views

In this article, we’re going to discuss the differences between the npm and npx. The difference between npm and npx is that npm is a package manager for managing dependencies and npx is a tool that allows you to run Node.js packages directly without installing them. Both are related to node.js but they are used for different purposes. First, let’s understand what npm is. npm The npm stands for Node Package Manager. It is a default Javascript package manager for Node.js that allows developers to install, share and manage dependencies. NPM is installed when NodeJS is installed on system. ... Read More

How to Show or Hide Element in React?

Rohit Kumar Dwivedi
Updated on 16-Dec-2024 10:35:15

85 Views

In this article, we are going to cover the implementation of dynamically showing or hiding elements in React. To understand this concept, you must be familiar with hooks in React. By leveraging hooks like useState, you can toggle and update the state to effectively control the visibility of an element. Approaches to Show or Hide Elements in React Using && Operator Using return null Using && Operator We have to change the state when a button is clicked, then it will determine the visibility of the element. With ... Read More

1 2 3 4 5 ... 13 Next
Advertisements