Hi,
In the following react component, I get “”Objects are not valid as react components”” error in the h1 tag of Welcome component, I looked up this error but couldn’t figure out how to solve it.
Thank you for your recommandations.
import React, {useState, useEffect} from ‘react’;
import ‘./App.css’;
import axios from ‘axios’;
function Welcome(props) {
return <h1>{props.name}</h1>;
}
function Summary() {
const [sum,setSum]=useState(
”
);
useEffect(() => {
const apiUrl = `/topic`;
axios.get(apiUrl)
.then((summary) => {
setSum(summary);
});
}, [setSum]);
return (
<div>
<Welcome name={sum} />
</div>
);
}
export default Summary;