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

useNumber contains content of useArray

Open mxzinke opened this issue 5 years ago • 9 comments

If I call the useNumber() hook, it basically uses the code of useArray hook and returns me an array.

At source folder in the sub-directory array is the file of the correct useNumber() hook.

mxzinke avatar Oct 08 '19 09:10 mxzinke

Oh lol. I'll take a look :) Or you can fix it with a PR :) Should be simple fix.

On Tue, Oct 8, 2019, 11:04 Maximilian Zinke [email protected] wrote:

If I call the useNumber() hook, that it simply uses the code of useArray hook and returns me an array.

At source folder in the sub-directory array is the file of the correct useNumber() hook.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kitze/react-hanger/issues/35?email_source=notifications&email_token=AA6B5342J5FHPYNTCIYQKWTQNRELDA5CNFSM4I6O7JC2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQJG34Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6B533BSAZZFQAUP4X5VELQNRELDANCNFSM4I6O7JCQ .

RIP21 avatar Oct 08 '19 09:10 RIP21

@mxzinke okay, I looked. It's all good. It reuses /array/useNumber version internally, to reuse the code. If I'm getting it right. So nothing is wrong I think. Clarify pls? Maybe some code example?

RIP21 avatar Oct 08 '19 12:10 RIP21

Okey I took a closer look and I was wrong. If I use the value of useNumber, then it returns NaN on decrease and on increase an Object-Array. I am not sure what is wrong on the code

mxzinke avatar Oct 08 '19 13:10 mxzinke

@mxzinke maybe initial state is missing? Dunno, will be nice to find and fix the issue and then cover with tests. Codesandbox.io repro maybe?

RIP21 avatar Oct 08 '19 13:10 RIP21

It would seem this is currently happening in the demo? Every example of useNumber is broken in some way.

brxck avatar Jul 05 '20 15:07 brxck

@RIP21 what about this one? not sure if we should close or fix something

kitze avatar Apr 02 '21 08:04 kitze

@kitze I'll try to look at all my OSS issues this evening. It's been awhile :)

RIP21 avatar Apr 02 '21 13:04 RIP21

Hi guys, this issue exists because in onClick={counter.increase}, the SyntheticEvent object will be passed as param, so for increase it will be transformed into [Object object] and NaN for decrease.

bianzheCN avatar May 21 '21 07:05 bianzheCN

Yup, sounds like true.

RIP21 avatar May 21 '21 09:05 RIP21