Comments (7)
This component is implemented in wrong way. Batching and async doesn't work with it. State based updates should be done with function updater like setToggle(v => !v)
.
from react-use.
I said implementation is wrong. Not usage.
from react-use.
Thanks guys, added your suggested fix:
from react-use.
I'm using it as per the docs.
The toggle function accepts one argument, an optional boolean, not a function.
The whole point is to delegate toggling logic to the useToggle hook. If the toggling logic was required in the updater function, this useToggle hook would have no purpose. It would just be a no-op wrapper around useState.
from react-use.
Apologies, I thought you were referring to my implementation of it.
from react-use.
It's been released today. Is it working now?
from react-use.
I believe this has been fixed.
from react-use.
Related Issues (20)
- UseKeyPressEvent doesn't work when non-english language is set HOT 1
- useMeasure dimensions out of sync in react18 HOT 2
- Please add a list of valid keys to https://github.com/streamich/react-use/blob/master/docs/useKey.md HOT 1
- useMedia deprecated methods HOT 1
- There is deprecated dependency in your nano-css HOT 1
- useWindowSize does not work on App Router (nextjs) HOT 1
- useCopyToClipboard: accept options object to pass to copy-to-clipboard HOT 2
- useCopyToClipboard: accept options object to pass to copy-to-clipboard
- [question]: How can I combine useMeasure with useHoverDirty HOT 1
- useLocalStorage doesn't not remove key on setValue(undefined) HOT 1
- useLocalStorage documentation: warn against calling with same key in multiple components HOT 3
- useLocalStorage without 'or undefined' HOT 2
- Breaking rules of hooks leads to incorrect behaviour in useLocalStorage
- useMedia throw "addEventListener is not a function" error occurs in browsers ios13.1 and below HOT 2
- a question, how to creat a shortcut for macos
- setValue function in useLocalStorage hook doesn't return the correct previous value
- Add useTitle option to restore original on unmount
- Security Issue HOT 6
- useStateWithHistory: initialState of function type are not handled correctly HOT 1
- useCookie does not react to changes in the passed in "cookieName"
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 react-use.