We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9b6980 commit c4ec69aCopy full SHA for c4ec69a
index.js
@@ -1230,7 +1230,13 @@ export function useThrottle(value, interval = 500) {
1230
}
1231
1232
export function useToggle(initialValue) {
1233
- const [on, setOn] = React.useState(initialValue);
+ const [on, setOn] = React.useState(() => {
1234
+ if (typeof initialValue === "boolean") {
1235
+ return initialValue;
1236
+ }
1237
+
1238
+ return Boolean(initialValue);
1239
+ });
1240
1241
const handleToggle = React.useCallback((value) => {
1242
if (typeof value === "boolean") {
0 commit comments