Category: React
-
In React, what’s the difference between onChange and onInput?
In React, what’s the difference between onChange and onInput? When working with React, you may come across two event handlers, onChange and onInput. While they may seem similar, there are some key differences between the two. The onChange event handler is triggered when the value of an input element changes. This means that the event…
-
How to repeat an element n times using JSX and Lodash
How to Repeat an Element n Times using JSX and Lodash When working with JavaScript, especially in the context of JSX, there may be times when you need to repeat an element multiple times. This can be useful for creating lists, generating placeholder content, or any other scenario where you need to duplicate an element.…
-
React Enzyme find second (or nth) node
React Enzyme: Finding the Second (or nth) Node If you are working with React and using Enzyme for testing, you might come across a situation where you need to find the second (or nth) node in your component’s rendered output. While Enzyme provides several methods to find elements, it doesn’t have a built-in method to…
-
Using “homepage” in package.json, without messing up paths for localhost
Using “homepage” in package.json, without messing up paths for localhost When developing a JavaScript application, it is common to use a package.json file to manage dependencies and configure various settings. One such setting is the “homepage” field, which specifies the base URL for your application when it is deployed. However, using “homepage” can sometimes cause…
-
React onClick – pass event with parameter
React onClick – pass event with parameter When working with React, you might come across a scenario where you need to pass both the event object and additional parameters to an onClick event handler. This can be useful when you want to perform an action based on the event and also pass some custom data…
-
React Child Component Not Updating After Parent State Change
React Child Component Not Updating After Parent State Change If you are working with React, you may have encountered a situation where a child component does not update even after the state of its parent component has changed. This can be a frustrating issue to debug, but fear not, we have some solutions for you.…
-
using history with react-router-dom v6
Using History with react-router-dom v6 React Router is a popular library for handling routing in React applications. With the release of version 6, there have been some changes to how history is handled. In this blog post, we will explore how to use history with react-router-dom v6 and discuss the different approaches to achieve this.…
-
How to get the width of a react element
How to Get the Width of a React Element When working with React, you may often find yourself needing to retrieve the width of a specific element. This can be useful for various reasons, such as dynamically adjusting the layout or performing calculations based on the element’s dimensions. In this blog post, we will explore…
-
How to make a rest post call from ReactJS code?
When working with ReactJS, you may come across the need to make REST API calls. In this blog post, we will explore how to make a REST POST call from ReactJS code. There are a few different ways to achieve this, depending on your specific requirements and preferences. Let’s take a look at two common…
-
React: useState or useRef?
React: useState or useRef? When working with React, you may come across situations where you need to manage state or access and manipulate DOM elements. Two commonly used hooks in React for these purposes are useState and useRef. In this article, we will explore the differences between useState and useRef and when to use each…