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

Do `useInterval` and `useTimeout` re-initialize on every re-render?

Open vfonic opened this issue 6 years ago • 7 comments

I'm not sure if something changed in the API for useEffect, but I think that, if you omit the second argument, it will re-run the effect on every re-render.

vfonic avatar Feb 20 '19 19:02 vfonic

Well, given a recent article from Dan Abramov I think the current hooks need to be updated in order to be performant.

dispix avatar Feb 20 '19 19:02 dispix

@dispix when you say "the current hooks" do you mean the hooks in this repo or the React hooks API?

It would be great to have some kind of notice or warning on the repo. Otherwise it seems like the repo is actively maintained, as the last change was about 2 months ago.

vfonic avatar Feb 20 '19 20:02 vfonic

The version 1.3.0 provides the updated hooks. Keep in mind that 2 months without an update for something as new as hooks is a very, very long time. I wasn't planning on actively maintaining this repository unless it is used, in which case I will definitely put the time and effort required. It just seemed to me that it didn't got enough attention.

dispix avatar Feb 20 '19 20:02 dispix

You're right, two months is a long time. I've found your repo through one of the "awesome-react-hooks" repos and at first thought it's maintained, since it's there. Then I figured that useInterval doesn't work as expected. :/

Don't maintain the repo because of me. I've copy-pasted most of the hooks to my own repo.

vfonic avatar Feb 20 '19 21:02 vfonic

Nooooo, this repo's awesome! Can't force you to maintain it but I'd be happy to help if it makes a difference. I think it'll get more attention as people start to adopt hooks more.

skipjack avatar Mar 22 '19 18:03 skipjack

@skipjack Well honestly I'm really glad you think so 😃 I mean if at least one person likes it then I'd be glad to maintain it ! But your help would be welcome of course.

dispix avatar Mar 22 '19 20:03 dispix

I mean if at least one person likes it then I'd be glad to maintain it!

Lol I appreciate that but I'm fully aware how time consuming open source can be, so don't maintain just for my sake. I guess my point is just give it some time, I think this package will get more traction.

I came across it through awesome-react-hooks as well but I did probe a lot of other packages for lifecycle recipes and this one seemed best. I can't imagine that other people who are going more stateless/functional wouldn't be out looking for something like this. Plus... I mean come on... the package name is perfect 😜

I'll stop spamming @vfonic's issue though, just saw the conversation above and figured I'd chime in with an upvote.

skipjack avatar Mar 22 '19 20:03 skipjack