GithubHelp home page GithubHelp logo

useStorageState about hooks HOT 3 CLOSED

alibaba avatar alibaba commented on May 3, 2024
useStorageState

from hooks.

Comments (3)

ttys026 avatar ttys026 commented on May 3, 2024

我理解既然要保存就不应该在 unmount 的时候 clear 掉 storageState,
是否需要暴露出一个 removeItem 的方法呢?
另外这里是否做成 { value, onChange } 这种形式,可以考虑一下

from hooks.

awmleer avatar awmleer commented on May 3, 2024

不传参数直接调用 setState() ,或者 setState(undefined) 就是 localStorage.removeItem 。。

from hooks.

awmleer avatar awmleer commented on May 3, 2024

{ value, onChange } 的感觉不是很有必要。。现在这样的API可以保证和 useState 的兼容性,对用户的使用来说非常友好。如果用户需要监听 state 的变化,那么也可以按照 useState 对应的处理方案,写一个 useEffect

from hooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.