Comments (3)
我理解既然要保存就不应该在 unmount 的时候 clear 掉 storageState,
是否需要暴露出一个 removeItem 的方法呢?
另外这里是否做成 { value, onChange } 这种形式,可以考虑一下
from hooks.
不传参数直接调用 setState()
,或者 setState(undefined)
就是 localStorage.removeItem
。。
from hooks.
{ value, onChange }
的感觉不是很有必要。。现在这样的API可以保证和 useState
的兼容性,对用户的使用来说非常友好。如果用户需要监听 state 的变化,那么也可以按照 useState
对应的处理方案,写一个 useEffect
。
from hooks.
Related Issues (20)
- useDebounceEffect & useThrottleEffect ,当 callback 被执行前,多了一次额外的 rerender HOT 1
- 官网很卡! HOT 3
- useEventEmitter的返回对象中,useSubscription只能订阅一次 HOT 1
- v2 官网文档样式错乱 HOT 7
- useInfiniteScroll mutate | 直接修改 data, 造成了不停的请求 HOT 2
- useKeyPress 执行问题 HOT 1
- I issued an error when I upgraded react-router-dom to 6.21.0
- 网站崩溃了 返回503 HOT 4
- [RFC] usePageCacheState HOT 1
- 希望useRequest能够新增一个不需要useRequest帮我管理请求结果的选项 HOT 6
- 去掉请求失败仍能放回上次的成功数据 HOT 5
- useDynamicList的getKey并不是唯一的key HOT 2
- docs(useExternal): text overflow of the box
- 想同时具备 useSetState 合并对象、useResetState 重置状态的能力,有没有这样一个 hook? HOT 6
- useEventListener 事件入参支持数组
- useClickAway错误调用 HOT 2
- 在antdPro中使用ahooks报错Cannot read properties of null (reading 'useState')老师,求解 HOT 1
- what's the initialData option for useRequest in v3? HOT 2
- useInViewport行为与文档不一致,期望更新小版本 HOT 2
- 使用useKeyPress注册一个快捷键,怎么取消注册? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hooks.