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)
- useRequest 开启 staleTime 缓存后轮询失效 HOT 1
- useRequest 在react18 开启严格模式下 data 无法正常返回数据 一直是undefined HOT 9
- useInfiniteScroll reload 重置问题 HOT 3
- useRequest 的 setCache 和 getCache 似乎不支持异步 HOT 1
- useRequest循环调用多次run, onSuccess只执行一次 HOT 6
- useRequest 在 React 18 部分场景下不兼容, 存在严重问题 HOT 2
- Can I customize the handshake headers when using useWebSocket? HOT 3
- useLocalSorageState无法监听全局localStorage修改的事件 HOT 1
- useKeyPress: ["alt.c"] seems do not work HOT 3
- useKeyPress second argument always undefined
- useRequest 会考虑把 http status code 纳入处理过程么? HOT 1
- BUG useClickAway 不可用 HOT 6
- useWebSocket 没有提供重置latestMessage的方法 HOT 2
- useAntdTable 初始化请求执行2次 HOT 2
- useRequest在严格模式StrictMode下,缓存失效 HOT 9
- useInViewport 弄一個triggerOnce的參數比較好 HOT 3
- [RFC] useEventBus HOT 7
- 能不能把useTimeout升级一下? HOT 5
- 官网白屏 HOT 1
- [RFC]useSwipeEvent
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.