From 3f7b638cd83cd73b1b9b466821ab4c10d8a596ad Mon Sep 17 00:00:00 2001 From: Jean-Christophe <> Date: Thu, 25 Jan 2024 10:27:10 +0100 Subject: [PATCH] change forme du useEffect : sortie de fetchData() --- src/components/personListing.component.jsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/personListing.component.jsx b/src/components/personListing.component.jsx index 74b6c02..09738a4 100644 --- a/src/components/personListing.component.jsx +++ b/src/components/personListing.component.jsx @@ -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} -- GitLab