Syncing Local Storage with React State

Syncing a React component's state to localStorage with useSyncExternalStore.