jeudi 21 octobre 2021

How to add React element to a component on a time based interval without causing a rerender?

I am not sure if React JS can do this, but is there a way?

setInterval(() => {
        ReactDOM.render(
            <h1 id = {count}>{count}</h1>,
            document.getElementById("drop")
        );
        count = count + 1;
    }, 1000);

This is the code I have so far, but it didn't work because it just replaces . The goal is for every two seconds, React will pick a word from an array of String and make it fall from the top of the page to the bottom [with React-Spring]. So, create a new React element and add it to the React Component every two seconds.




Aucun commentaire:

Enregistrer un commentaire