alibaba / alibaba/hooks

useSessionStorageState无法使用listenStorageChange跨越tab共享

Open
#2,851 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15k
Forks
2.8k
Avg merge
15h 7m
Merged PRs (30d)
2

Description

useSessionStorageState无法像uselocalStorageState使用listenStorageChange跨越tab共享(文档说和localStorage用法一致)
```javascript
function Counter() {
const [count, setCount] = useSessionStorageState('use-session-storage-state-demo, {
defaultValue: 0,
listenStorageChange: true,
});

return (


setCount(count! + 1)}>
count: {count}

setCount()}>Clear

);
}

```

Contributor guide

Open the contributing guide

Research direction

Start by comparing the useSessionStorageState and useLocalStorageState entry points, focusing on how listenStorageChange handles cross-tab updates. Reproduce the example with two tabs and confirm that enabling the option synchronizes changes and clearing between them.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.