react-hanger icon indicating copy to clipboard operation
react-hanger copied to clipboard

Add useClickAway

Open geobde opened this issue 4 years ago • 7 comments

React hook useClickAway() that reacts to clicks outside the bound element, and calls the expression that is passed in when this event is detected.

geobde avatar Aug 25 '20 13:08 geobde

Hey man. I'm currently on vacation I'll definitely have some inputs later (regarding naming and Typescript maybe), I'll feedback with all stuff at once to keep it clear and single change for you and not multiple back and forths :) I'll try to check it out within this week for sure. Maybe tomorrow evening or this evening.

RIP21 avatar Aug 25 '20 15:08 RIP21

It already exists: https://github.com/streamich/react-use/blob/master/docs/useClickAway.md

kitze avatar Aug 27 '20 07:08 kitze

The question is, do we want to add stuff to react hanger that already exists in other hooks libraries 🤔

kitze avatar Aug 27 '20 07:08 kitze

I think it's not that bad idea, especially if those others are not properly typed :) Or don't have typings at all :)

Although I need to do a little research. I plan to do major release soon. Removing something that I'm not sure people are using or was a good idea to add :)

So we need to add all that new stuff to it maybe and finally do something about sizzy hooks. There are a lot of them :) Type them, test them and improve if needed.

On Thu, Aug 27, 2020, 08:45 Kitze [email protected] wrote:

The question is, do we want to add stuff to react hanger that already exists in other hooks libraries 🤔

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kitze/react-hanger/pull/56#issuecomment-681712850, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6B5374S3E2NQRSORY4FITSCYFIRANCNFSM4QKVVLTQ .

RIP21 avatar Aug 27 '20 10:08 RIP21

Ok. As I see react-use has this one with typescript so I think this one is pretty useless. So I would keep this one out of the react-hanger. IMO we should ditch react-hanger completely in favor of react-use and just merge our hooks with theirs :P @kitze whatdaya think? :D

RIP21 avatar Sep 06 '20 16:09 RIP21

@RIP21 I don't agree because all of their hooks are array based, and there might be differences in individual hooks (i.e they have different methods for useNumber)

kitze avatar Apr 02 '21 07:04 kitze

@geobde wouldn't it be better for this hook to create a ref inside and return it as a result of the hook? I think that'll make it more reusable.

kitze avatar Apr 02 '21 07:04 kitze