Skip to content
Advertisement

react native useEffect run into dead loop:

JavaScript

}

after the code is executed ,the terminal continues showing :

JavaScript

i have confusion about this ,useEffect function should be rendered once .However ,it seems continuing to be redered .

Advertisement

Answer

You did not add a dependency array to the useEffect function. Therefore, it is bound to be an infinite reRendering.

And react does not recommend let. Use the status value.

You can add a dependency array

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement