Add the following command to install Ant Design UI React component to a react project npm install antd –save
Category: JavaScript
compare Dates
Comparing the “date” element of each format and exclude any “time” element. Then with both dates converted to milliseconds, simply compare the values. You could do something like this. If dates are equal it returns 0, if the first date is less that the second then return -1, otherwise return 1. Javascript function compareDates(milliSeconds, dateString)… Continue reading compare Dates
Mastering Performance in React with useMemo
React is a powerful library for building dynamic user interfaces, but as your application grows, performance can become a concern. One of the tools React provides to optimize performance is the useMemo hook. In this article, we’ll explore what useMemo is, why it’s useful, and how to implement it effectively in your React projects. What… Continue reading Mastering Performance in React with useMemo
React Suspense for Data Fetching
Why This is Interesting Suspense Magic: React Suspense allows the component to “suspend” rendering while the data is being fetched, showing a fallback UI (like “Loading…”) until the data is ready. This eliminates the need for manual loading states with useState and useEffect. Caching Twist: The fetchUserData function uses a Map to cache results, so… Continue reading React Suspense for Data Fetching
Mastering useCallback in React
Introduction React has revolutionized the way we build user interfaces, and its hooks API has made state management and side effects more intuitive. However, as applications grow, performance can become a bottleneck. One tool in React’s optimization toolbox is the useCallback hook. In this article, we’ll explore what useCallback is, when to use it, and… Continue reading Mastering useCallback in React
A Practical Example Of useMemo
Let’s say you’re building a dashboard that filters a list of users based on a search term. Without useMemo, the filtering logic might run on every render, even if the data or search term hasn’t changed. Here’s how you might implement this without useMemo: import React, { useState } from ‘react’; function UserList({ users })… Continue reading A Practical Example Of useMemo
Function To Render the Data in Table Structure Using HTML
The function in the javascript is used to display the sales order items in a table structure. <script> let removedItems = []; let addedItems = []; let deleteSOPersmissionFlag = “${deleteSOPersmission}”; document.addEventListener(“DOMContentLoaded”, function () { let scanButton = document.getElementById(“scanItemBtn”); let fetchButton = document.getElementById(“fetchItemBtn”); let saveButton = document.getElementById(“savebutton”); let deleteBtn = document.getElementById(“deleteOrderBtn”); const cancelOrder = document.getElementById(“cancelBtn”); if… Continue reading Function To Render the Data in Table Structure Using HTML
Some JavaScript functions that can significantly optimize the primitive approaches programmers might use for certain tasks:
reduce const numbers = [10, 20, 30]; const sum = numbers.reduce((total, num) => total + num, 0); console.log(sum); // 60 fromEntries const obj = { a: 1, b: 2, c: 3 }; const transformed = Object.fromEntries( Object.entries(obj).map(([key, value]) => [key, value * 2]) ); console.log(transformed); // { a: 2, b: 4, c: 6 }… Continue reading Some JavaScript functions that can significantly optimize the primitive approaches programmers might use for certain tasks:
jQuery to disable button action
To disable a button action using jQuery, you can set the attribute of the button to . Here’s a simple example: jQuery(‘#button_id’).prop(‘disabled’, ‘disabled’);
How Async/Await Can Slow Down Your Node.js App
n the world of Node.js, async/await has become a staple for handling asynchronous operations. It’s clean, easy to read, and feels synchronous. But as wonderful as it sounds, misusing async/await can introduce performance bottlenecks that slow down your application. If your app feels sluggish despite using async/await, this post is for you. Why Async/Await Feels Slow Under the hood,… Continue reading How Async/Await Can Slow Down Your Node.js App