- 12 hours
- Medium
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 3/3/22
Incorporate Data Into a React Application With Hooks
Evaluated skills
- Incorporate data Into a React application with hooks
Question 1
Which hooks are required for making API calls?
Careful, there are several correct answers.useEffect
useContext
useFetch
useState
Question 2
I want to make an API call on the URL
http://localhost:8000
which returns adata
object. Which code snippets will let me do this effectively?Careful, there are several correct answers.useEffect(() => { fetch(`http://localhost:8000`).then((response) => response.json().then(({data}) => { setData(data) }) ) })
useEffect(() => { async function callApi() { const response = await fetch(`http://localhost:8000`) const { data } = await response.json() setData(data) } callApi() }, [])
useEffect(() => { useFetch(`http://localhost:8000`).then((response) => response.json().then((data) => { setData(data) }) ) }, [])
useEffect(() => { fetch(`http://localhost:8000`).then((response) => response.json().then(({data}) => { setData(data) }) ) }, [])
Question 3
Which elements are required for creating a Context and getting it in a function component?
Careful, there are several correct answers.Connecting to data with
connect
Using a
Provider
to which avalue
object is passed to wrap parent componentsGetting data with
useContext
Creating a Consumer to consume the data
Ever considered an OpenClassrooms diploma?
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring
Find the training program and funding option that suits you best