Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[useToggle] Rewrite as a wrapper hook

See original GitHub issue


While the current implementation of useToggle handles a given state variable specially, wrapper syntax would allow it to control custom states (e.g. the one returned by useLocalStorage).

Basic example

function Example() {
  const [isPressed, togglePressed] = useToggle(useLocalStorage('isPressed', false));

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

kripodcommented, Oct 9, 2019

@Jfelix61 Thanks for your contribution! If you need any kind of assistance, I’m glad to help.

kripodcommented, Oct 10, 2019

This has been resolved by #78.

@Jfelix61 If you ever decide to contribute again, please refer the corresponding issue (e.g. this one) in your pull request using keywords if possible. Thank you for your efforts!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toggle state on and off with React Hooks - Josh W Comeau
This hook uses React.useCallback in order to preserve the reference to the setter function; without this wrapper, the toggle function would ...
Read more >
useToggle React Hook - useHooks
Hooks are a feature in React that allow you use state and other React features without writing classes. This website provides easy to...
Read more >
Custom react hook useToggle in Typescript - Stack Overflow
You might need to define the return type of your hook. It should look something like this. import { useState } from 'react';...
Read more >
Creating Custom React Hooks — useToggle | by Irmak Esin
A custom hook is a Javascript function that starts with “use” and that can call other hooks. The main reason to create a...
Read more >
kodingdotninja/use-toggle - GitHub
Toggle custom hook and component wrapper for React - GitHub - kodingdotninja/use-toggle: Toggle custom hook and component wrapper for React.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found