Home>
The simplest React.js code doesn't work for me I would really like to understand what exactly is wrong, any help is helpful. Thanks a lot in advance)
Code:
import './style/App.css';
import React, {useState, useEffect} from 'react';
function App() {
const[prisvoenie, setPrisvoenie]= useState({});
useEffect(()=> {
fetch('https://jsonplaceholder.typicode.com/users')
.then((response)=> response.json())
.then((res)=> {
setPrisvoenie(res);
})
},[])
return (
<div className="App"> {private}
</div> );
}
export defaultApp;
-
Answer # 1
Related questions
- javascript : Why do I get a jsx file instead of js after building a project with webpack using babel
- reactjs : Question about the structure of a react application
- javascript : How to restart an existing React app?
- javascript : React. Send a get request to the server when pressing Enter
- javascript : Running webPack 5 in development mode does not see html page
- javascript : Problem with Route
- javascript : JS: wrap links found inside a string in an element
- javascript : How to optimize useSelector redux
- javascript : render {routes} in react
The variable prisvoenie is an object (it will become an array after the request), and react does not allow objects to be rendered, you need to do prisvoenie.map() and return the markup from it