I cannot display a property of my JSON (DataUser.name.first)
` import React, {useEffect,useState}from 'react'; import Article from '../components/Article'; import '../styles/containers/Home.scss'; const Home = () => { const [DataUser, setDataUser] = useState("Cargando"); useEffect(() => { const Cargar = async () => { let respuesta = await fetch(`https://randomuser.me/api/`); let respuestaJSON = await respuesta.json(); setDataUser(respuestaJSON.results[0]); }; Cargar(); }, []); return ( <> <div className='Home'> {console.log(DataUser.gender)} /*:)*/ {console.log(DataUser.name.first)} /*:(*/ </div> </> ); }; export default Home; ` I'm trying to pass properties to a component in react, when I pass the cell number everything is ok. But when I try to pass the name I get an error.
My JSON "results": [ { "gender": "male", "name": { "title": "Mr", "first": "Elliot", "last": "Thompson" }, }, ],
I want to get the value that is inside name. The problem that I see is that we have an object inside another object. and not an array inside an object.
DataUser.name.first(instead ofDataUser.namewhich is an object and not a string) toArticle?<Article cell={DataUser.cell} name={DataUser.name.first}/>?