In App.js
export default function App() {
const [data, setData] = useState(null);
useEffect(() => {
fetch("https://api.github.com/users/deepakranga1801")
.then((response) => response.json())
.then(setData);
}, []);
return (
<div className="App">
<Card item={data} />
</div>
);
}
In Card.js
function Card(props) {
return (
<div><h1>{props.item.name}</h1></div>
);
}
I'm trying to pass data fetch from API from app.js
to card.js
but through
TypeError Cannot read property 'name' of null.