Category "javascript"

How to re-render react-table in .js when data changes in another .js

I am new to react-table and trying to re-render a react-table when data supplied to it changes. Is there anyway to do so? I have tried using useEffect() with no

calculate compound profit in javascript

I have to calculate compound profit. for example, I have $100, increasing 10% monthly, and I have to calculate the total profit for 12 months. And I need a prof

How do I fit the entire content in one page when printing it to PDF?

I am using jspdf and html2canvas. Printing the component would make the footer go to the next page. How can I set this where it will dynamically resize to fit i

A problem that i am having making conway's game of life in react (nextjs). when i press the Random button while it is running, it starts flickering

Here is a the code for you to try. both button works fine while the game is paused or running very fast, but if i set the timeout above 100 or 200 ms and the ga

A problem that i am having making conway's game of life in react (nextjs). when i press the Random button while it is running, it starts flickering

Here is a the code for you to try. both button works fine while the game is paused or running very fast, but if i set the timeout above 100 or 200 ms and the ga

React useEffect does not work as expected

useEffect(() => { const method = methodsToRun[0]; let results = []; if (method) { let paramsTypes = method[1].map(param => param[0

Why do clicks within Popover.Panel close the panel when within Tab.Panel?

I've been using @headlessui/react for a project and it's helped me be very productive! But I've found an issue where one component interferes with another. I th

A component is changing an uncontrolled input to be controlled

I am trying to do the discounted price logic Discount price should have the default value of actual price , because 0% discount means the discount price is same

Nodejs can't find file

I have script.js on desktop and test.js in a folder on desktop. Case 1 When I write node script.js in Mac terminal, I get this error: > node:internal/modules

Content-Disposition: download file automatically

The API call to the server is returning a zip file with Content-Disposition in format attachment, <filename> I am using FileSaver's saveAs to save the fil

Aggregates with Knex and Javascript

I have an application built using javascript, react, express, and postgreSQL. I have used knex to create and seed my database. The majority of the functions suc

Next.js is not recognizing '@types/react'

When I try to run my Next.js app with npm run dev I get an error message saying that I don't have the required packages to run Next with Typescript: Please inst

Mongoose query always returns empty array

Im trying to make a greater than query but it always returns an empty array. const productSchema = require("./productsSchema"); const getProductsGreaterThan

Checking if the entered date is the start of a quarter

Good afternoon! Can you please tell me how to implement a function that checks if the passed date is the beginning of the quarter? I tried to implement validati

Electron not starting properly due to SIGTRAP

I am getting into Electron to try to begin building desktop applications. I am running into this error: /home/me/dev/my-electron-app-2/node_modules/electron/dis

Capture text after multiple optional strings into named group with Regex

I am trying to extract multiple strings using different patterns from one long string. Here is an example of the input string: [Update 2]Number of students: 5[

Insert data after event.target (Owl Carousel)

I am following this codepen here to insert the current and total number of slides on an Owl carousel. Trouble is it targets a div with ID #counter. So if there

React-router showing invalid hook call

An invalid hook error occurred in my react app caused by react-router but I can't seem to detect where it's coming from. The full error reads as follows: Error:

Target map()'ed items one by one

I want to create a contact form where the form fields are changed after they are filled. For example when you fill the email field, you press enter or click the

require() of ES modules not supported

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\...\node_modules\normalize-url\index.js [0] require() of ES modules is not supported. [0] require