React infinity state on console.log() using hooks why is that?

import React, {useState} from "react";
 
const App = ()=>{

    let [state, setState] = useState([])

    fetch("https://jsonplaceholder.typicode.com/users")
    .then(result => result.json())
    .then(data => setState(data))

    
    console.log(state)

    return(
        <h1>Hey there</h1>
    )
}

export default App;


Read more here: https://stackoverflow.com/questions/64405157/react-infinity-state-on-console-log-using-hooks-why-is-that

Content Attribution

This content was originally published by gamerC at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: