how to avoid re-render when i have more than one setState in useEffect ?
i want to make 2 API calls and set 3 different states in useEffect ( when component did mount ) and only one re-render
something like this
useEffect(()=>{
axios.get('http://localhost:81/api/myapi/')
.then(res=>{
setName(res.data['name']);
setPrice(res.data['price']);
})
axios.get('http://localhost:81/api/mysecondapi/')
.then(res=>{
setColors(res.data['colors']);
})
},[]);
i want only one render after all the sets. i know it's correct to a re-render after every setStates, but how can i make this to do only one ? is it good to put all states in an object ? like class state ?