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.
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.