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