Answer the question
In order to leave comments, you need to log in
How to fix error in React: "Too many re-renders"?
<>
<h2 className='about-me__text'>
...
</h2>
<h4 className='about-me__text'>
...
</h4>
<p className='about-me__text'>
...
</p>
<p className='about-me__text'>
...
</p>
<p className='about-me__text'>
...
</p>
</>
const [textNodes, setTextNodes] = React.useState()
setTextNodes(Array.from(document.querySelectorAll('.about-me__text')))
Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
Answer the question
In order to leave comments, you need to log in
const [textNodes, setTextNodes] = React.useState(()=>Array.from(document.querySelectorAll('.about-me__text')))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question