Skip to content
Snippets Groups Projects
Commit 3f7b638c authored by Jean-Christophe's avatar Jean-Christophe
Browse files

change forme du useEffect : sortie de fetchData()

parent fbf7ff9c
Branches
Tags
No related merge requests found
......@@ -12,17 +12,16 @@ const PersonListing = props => {
const [persons, setPersons ] = useState([]);
const fetchData = async () => {
const data = await mockFetch('http://source.of.data/persons',1000);
setPersons( data );
}
useEffect( () => {
console.log('component did mount');
const fetchData = async () => {
const data = await mockFetch('http://source.of.data/persons');
setPersons( data );
}
fetchData();
}, []);
const personComponents = persons?.map(person => <Person
const personComponents = persons.map(person => <Person
{...person}
{...props}
key={person.id}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment