One common problem where developers face when using the React Router is unable to redirect to a route programmatically, or the Redirect component of the react router not working. Redirect not used inside a Router The Redirect component needs to…
In this article, we will explore how to reload a page on the route change in React. This is a very common requirement when building the dynamic web pages using reactjs. React router allows us to define routes and map…
In this article, we will discuss how to refresh a page using React Router Link. React router allows developers to define routes for different components and provides a simple way to navigate between them. Similarly like the HTML anchor tag,…
In this article, we will see how to compare oldValues and newValues using the React Hooks useEffect(). In some cases, we may need to perform certain actions only after the value in the state changes. In such a scenario, we…
In this article, we will see how to use the setState() callback with React hooks. The setState() method is used to update the state of a component. When we call the setState(), React updates the component’s state and re-renders the…
In this article, we will see how to add the custom attribute to the element. What is a custom attribute in React? A custom attribute in React is an HTML attribute that isn’t already built into the library. Custom attributes…
In this article we will see how to generate a random hash string using javascript. Here are the different hash strings that we will see how to generate. Following is the example on how to generate the random hash string…
In this article, we will discuss how to implement a random sleep in JavaScript. Defining the sleep method In javascript we can simulate the sleep functionality by using the setTimeout. In the below example, we defined our own sleep function…
In this article, we will discuss how to calculate the number of days between two dates in JavaScript. By using the Date object in the JavaScript we can easily achieve this task. Following is the example of how to calculate…
In this article, we will how to generate a random date between two dates in JavaScript. First, we should define the start and end date between which we want to generate a random date. We can do this in JavaScript…