React & APIs Flashcards

1
Q

How would you handle error states from an API call in a React component?

A

Using state to represent error, loading, and data states and conditionally render based on that state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you make a component re-fetch data when a prop changes?

A

Using the useEffect hook with the prop in the dependency array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly