Doing a (GET) fetch request
class HelloMessage = function({name}){
const [state, setState] = useState()
useEffect(()=> {
fetch(your_url)
.then(res => res.json())
.then(data => {
setState({your_state:data})
})
}, [])
render() {
return <div>Hello</div>
}
}
- Next: A simple React function component
- Previous: A Simple React Component