Clear all the timeout objects from webpage in-Javascript

Clear all the timeout objects from webpage in Javascript

setTimeout function is used to achieve asynchronous tasks in JavaScript. The return value of setTimeout is an Integer. This value can be passed to clearTimeout method to clear that timeout….

Submit formik form using React-Query mutations

Submit formik form using React-Query mutations

In this article you will learn how to create forms using Formik library, and how to submit the forms using React-Query mutation hook. We will cover the…

How to mock and test Intl.DateTimeFormat in Jest

How to mock and test Intl.DateTimeFormat in Jest

Intl.DateTimeFormat provides powerful functionalities to format dates. This article demonstrates how to mock and test Intl.DateTimeFormat with Jest. Example Consider we have the following function that does…

How to parse a URL query parameters in javascript

How to parse a URL query parameters in javascript

To parse the URL query parameters in Javascript, we can use the URLSearchParams interface, which has some utility functions that allow us to easily parse/build URLs. Examples…

useNavigate may be used only in the context of a component

Jest useNavigate may be used only in the context of a router

While working with Jest and React-Testing-Library, you might encounter the following error: useNavigate() may be used only in the context of a <Router> component There are two…

useNavigate may be used only in the context of a component

useNavigate may be used only in the context of a component

If you’ve ever faced the following error in React: useNavigate() may be used only in the context of a component This error throws in useNavigate hook.  This happens…

How to mock React-Router-Dom hooks in Jest

How to mock React-Router-Dom hooks in Jest

To mock React-Router-Dom hooks in React you need to do the following: Mock the library React-Router-Dom using jest.mock Import non-mocked React-Router-Dom, so that we can use the…

 How To Dynamically load a JavaScript file in React

How To Dynamically load a JavaScript file in React

Introduction Some use cases require loading a specific Javascript script conditionally, this article will demonstrate how to dynamically load a javascript file in React once a particular…

How to change the styles of MUI TextField In React

How to change the styles of MUI TextField In React

MUI library is a great library that offers a comprehensive suite of UI tools that helps ship new features faster. Sometimes we would like to customize the…