Hands-on practice for this lecture. Work through the exercises and quizzes to reinforce what you've learned.
Exercise 1 of 1
Four questions on useSyncExternalStore — what getSnapshot must return, why subscribe needs a cleanup, the tearing problem, and when getServerSnapshot is required.
const count = useSyncExternalStore( subscribe, getSnapshot, getServerSnapshot );
What does getSnapshot need to return?
function subscribe(listener) {
store.listeners.push(listener);
// missing something
}What must subscribe return?
What problem does useSyncExternalStore solve that useState does not?
When is getServerSnapshot required?
0/4 answered