Giter VIP home page Giter VIP logo

captain-hook's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar joshreep avatar

Watchers

 avatar

Forkers

sam-borg

captain-hook's Issues

add useWhyDidYouUpdate hook

Is your feature request related to a problem? Please describe.
I'm always frustrated when I have lots of unnecessary renders and I'm not sure how to find what's causing it

Describe the solution you'd like
I'd like a hook that prints out in the console why a component rerendered if no values changed

create useKeyPress hook

Summary

As a developer, I would like to have a hook that can make it easy to detect when a user is pressing a specific key on their keyboard so that I can fire off a callback on keypress.

Implementation

  • This request takes inspiration from this recipe.
  • The Hook should provide type safety.
  • You could also utilize the useEventListener hook to make registration and unregistration easier.

Proposed Signature:

export default function useKeyPress<T extends Element>(targetKey: string, element?: T): boolean

Acceptance Criteria

  • The hook takes in a string that represents the target key, and an optional element to bind the listener to.
    • If no element is passed in, the window object should be used to bind the listener.
  • The hook should remove the listener when the component unmounts
  • The hook should return true when the target key is being pressed and false when the target key is not being pressed.
  • The hook should return false when any key other than the target key is pressed.
  • There should be adequate test coverage
  • There should be a README.md file that provides good documentation about how the user will use the hook.

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.