Actualmente estoy aprendiendo los conceptos básicos de ReactJs. Estoy tratando de pasar un objeto anidado a "weatherValues". Después de hacer eso en la función fetchData, no funciona y devuelve el valor "nulo" original sin pasar el objeto anidado de fetch a setState. Por favor ayuda.
function App() { const [dLocation, setDLocation] = useState('London'); const [defaultLocation, setDefault] = useState(true); const [weatherValues, setWeatherValues] = **useState(null)**; const **fetchData** = () => { fetch(`${api.API_URL}?key=${api.API_KEY}&q=${dLocation}&days=${api.API_DAY_DATA}`) .then(response => response.json()) .then(data => { **setWeatherValues(data)** //setWeatherValues({...weatherValues, ...data}) //weatherArray = {...weatherArray, ...data}; console.log(weatherValues) console.log(data) } ); } useEffect(() => { if(defaultLocation === true){ **fetchData();** //console.log('Yes') // setWeatherValues(weatherArray) //console.log(weatherValues) } setDefault(false); }) return ( ) } export default App;