useSessionStorageState无法像uselocalStorageState使用listenStorageChange跨越tab共享(文档说和localStorage用法一致)
function Counter() {
const [count, setCount] = useSessionStorageState('use-session-storage-state-demo, {
defaultValue: 0,
listenStorageChange: true,
});
return (
<div style={{ marginBottom: '8px' }}>
<button style={{ marginRight: '8px' }} onClick={() => setCount(count! + 1)}>
count: {count}
</button>
<button onClick={() => setCount()}>Clear</button>
</div>
);
}