Explore all blogs
ERESOLVE unable to resolve dependency tree error when installing npm packages
To solve ERESOLVE unable to resolve dependency tree error when installing npm packages, ignore the peerDependencies by --legacy-peer-deps flag, downgrade the npm version.
Event Loop and Callback Queue in JavaScript
The event loop keeps monitoring the call stack and callback queue for executing callback functions. Read more about web APIs, callback queue, microtask queue, event loops, and starvation.
Expected an assignment or function call and instead saw an expression in React
To solve the error “Expected an assignment or function call and instead saw an expression” give a return statement to all functions in React components.
Expected `onClick` listener to be a function, instead got a value of `string` type
To solve “Expected `onClick` listener to be a function, instead got a value of `string` type.”, make sure to pass a function to the onClick prop of an element.
export 'withRouter' (imported as 'withRouter') was not found in 'react-router'
Error "export 'withRouter' (imported as 'withRouter') was not found in 'react-router'" occurs when we import withRouter from react-router which is removed in V6
Factory Design Pattern in JavaScript
Factory allows you to handle all the object creation in a centralized location which helps the code clean, concise, and maintainable. Understand deeply with examples.
Find greatest common divisor (GCD) in JavaScript
Find the Greatest Common Divisor(GCD) of two numbers using the Euclidean algorithm in javascript. Calculate GCD for a given integer array.
Get the current route using React Router
To get the current route with React Router, use the useLocation() hook. Use withRouter higher-order component in class component for current URL pathname
Get the Mouse Position (coordinates) in React
To get the Mouse position (coordinates) in React, use mousemove event and access event properties clientX and clientY for coordinates of the cursor on window.
Handle double click events in React
To handle the double click events in React, pass an event handler function to onClick prop and check the event.detail property to determine the click count.
How to check internet connection(online or offline) in React
To check the internet connection(online or offline) in React, use the navigator.onLine property which returns Boolean whether the browser is online or offline.