4,754 questions
0
votes
1
answer
120
views
After polling a server using setinterval, file will download but won't open in a new tab
I am polling a server, using setInterval, until the pdf's that I want to download are ready...Once the pdfs are ready to download, I clear the interval, and then I call a function
async function ...
1
vote
1
answer
46
views
React Hooks and Events [duplicate]
var [testVar,setTestVar]=useState(0)
var showTestVar=()=>{
console.log(testVar)
}
var effectTest=()=>{
setTestVar(1)
setInterval(showTestVar,1000)
}
I want to have a ...
3
votes
1
answer
59
views
Why does consoling prints the same value but state gets updated when used inside useEffect - React
In a video I saw creating a progress bar and updated its value using state and wrapped it inside setInterval for updating it every 15 millisecond and the whole being wrapped inside useEffect, with no ...
1
vote
1
answer
40
views
what triggers change detection when using OnPush and setInterval outside angular zone with markForCheck?
I couldn't really understand what is causing change detection to run in the below code. I understand that markForCheck doesn't do it but something must do it because the view is updated if you play it ...
1
vote
0
answers
69
views
writeFileSync fails when called inside of setInterval
This is really a head scratcher...
I'm running Node 22.9.0 on a raspberry PI (Linux raspberrypi 6.1.21-v8+)
My script, which is run as root, can write a new file in the current directory and update ...
5
votes
4
answers
162
views
Loop inside setInterval does not iterate over the second interation
I have a useTypewriter hook that seems to skip the second iteration since the i never logs as 1. Why is the code not working? The output should be howdy, not hwdy.
Here is the full code:
const { ...
2
votes
0
answers
38
views
Firefox - Javascript setInterval WAY WAY off [duplicate]
I'm trying to scroll text up the screen in about 4min +/- a few seconds doesn't even matter, along with a 4min audio.
To follow it, I've muted the audio 1 second every 10 seconds.
I display the ...
2
votes
3
answers
57
views
How to use useState, Dispatch input?
Consider this code:
const [seconds, setSeconds] = useState<number>(START_VALUE);
useEffect(() => {
const intervalId = setInterval(() => {
setSeconds((previousSeconds) => ...
0
votes
1
answer
64
views
Delayed function execution of setInterval
I'm trying to delay the execution of the setInterval function, which is set at 2000.
Ideally, I would like the function to be executed after 10000 at every refresh of the page + after each hide on ...
0
votes
1
answer
46
views
Get SVGator Javascript API to work in a timer loop
I have a 4 second SVGator animation that needs to run in it's entirety, then have the last 2 seconds loop indefinitely. I've exported as SVG/Javascript, then used the following JS code...
const ...
2
votes
1
answer
122
views
Javascript loop to wait for input from external source (Android tasker)
I am having a hard time with wait loops in JavaScript to wait for content from an external source (tasker).
In particular I have an HTML document with JavaScript (shown in a WebView element inside a ...
0
votes
0
answers
31
views
setInterval() alternative for web for inactive windows/ tabs [duplicate]
The setInterval() web API does not work when the browser tab is inactive. Is there any alternative for it that can keep the timer intact even when the browser tab/ window is inactive?
0
votes
1
answer
43
views
Updating Dynamic changes to fetching Data
I am stuck at the moment. I created the funcitonanilty to control how often data is is fetched using calculation of milliseconds to seconds,munutes and hours, which seems to be working fine.
The issue ...
2
votes
1
answer
45
views
How do I change the background colour of a class at midnight everyday rather than by a user event
Currently I have a piece of code that changes the background colour of a class every 24 hours. However if a user refreshes the page, the 24 hour cycle starts from the beginning – so they would only ...
0
votes
1
answer
57
views
Using setInterval in javascript [duplicate]
I modified a javascript code using setInterval to alternate between two messages using innerHTML. I tried document.write and it works. But innerHTML does not work.
// Create global interval and ...
-2
votes
2
answers
41
views
The state is not updating correctly inside setInterval of useEffect in react
I'm facing issue in updating the setStartTime inside setInterval function.
I want to update the startTime every minute. To update that, I've created a useRef and storing the value in timeRef.current. ...
0
votes
0
answers
193
views
ReactJS and Router DOM - Memory leak and persisting setInterval of an async function in a useEffect
I'm trying to set up a setInterval in a useEffect for an async function that fetches from a URI. I'm using React Router DOM to set up a few pages for the app. The problem I'm facing is that a memory ...
0
votes
3
answers
170
views
How does one enforce a chron-job to be executed exactly at every possible 5 minute mark (0:00, 0:05, 0:10) regardless of the chron-job's start time?
I have a JavaScript function of chrome extension that I need to run at exact 5-minute intervals, synchronized with the current time. For example, it should run at 5:00, 5:05, 5:10, and so on, ...
1
vote
0
answers
208
views
How to reactively display websocket.readyState in vue3?
I want to display websocket.readyState in component reactively. But it doesn't change the display status in a timely manner. It always change display at next time.
The code can't work properly:
let ws ...
0
votes
0
answers
50
views
difference in setInterval() speed on different browsers [duplicate]
let scramble = document.getElementById('scramble');
let timer = document.getElementById('timer');
const possibleMoves = ["R", "R'", "R2", "L", "L'", &...
0
votes
0
answers
63
views
Problem with useEffect() in React project
I've got this React app which sends a 'Post' request. The problem is that: i'm using useEffect(() to automate the sending process
of my messages and the application is not capturing the "...
0
votes
2
answers
69
views
changing the width of a div with setinterval
I have this code with css animation:
@keyframes progress-bar {
0% {
width: 0;
}
50% {
width: 100%;
}
100% {
width: 0;
}
}
.box {
position: relative;
height: 3px;
...
0
votes
2
answers
71
views
Run clearInterval with IntersectionObserver
I have a short code that runs a setInterval only when the element is in view, but for some reason it won't cancel when the element gets out of view. I don't know if I misunderstood InteractionObserver ...
0
votes
1
answer
64
views
Generate text in HTML canvas from the center printing one character at a time, with string dynamically adjusting to the formatting
I'm building a website that draws a string into a canvas one character at a time, I've managed to code this first part, but what I'm now trying to do is making the text generate on the center and ...
1
vote
3
answers
77
views
IF Else statement not properly worked in setInterval() function while creating count-down timer
Even after adding if else statment inside setInterval() function to clear the interval once my time variable reaches 0, the setInterval() is still running with negative time value.
Please specify what ...