react-dice-complete icon indicating copy to clipboard operation
react-dice-complete copied to clipboard

Dice rolling automatically on render

Open timB73 opened this issue 5 years ago • 3 comments

This seems to have cropped up from nowhere. It used to be that it wouldn't roll on render, but suddenly everywhere I try it the dice is automatically rolling with the value 4.

I was able to reproduce it in Sandbox, but it's weird because I'm not getting the same behaviour on my main production branch, using the same version and I can't figure out why.

https://codesandbox.io/s/busy-keldysh-oefwf?file=/src/App.js

timB73 avatar Aug 01 '20 11:08 timB73

Ok version 1.2.0 works perfectly, I guess I must have had different versions after all (I had updated my dev version to latest version after I encountered the problem to see if it would fix it, so not sure which version it was originally).

I looked through the code a bit, and in version 1.2.1 you introduce the defaultRoll prop, but you've set the default prop value of this to 4, so that's why I was getting 4. However I'm not sure the reason for the roll animation starting automatically on render.

timB73 avatar Aug 04 '20 20:08 timB73

Default roll is likely because you have are not calling it via a function like onClick={() => blah}. The two parenthesis are important.

The1Percent avatar Oct 31 '20 04:10 The1Percent

The dice are still rolling every time they re-render. How can I prevent that?

joey-carlisle4 avatar Dec 16 '20 18:12 joey-carlisle4

@timB73 can you retest with the latest version of the library and see if you are still seeing the issue?

AdamTyler avatar Mar 22 '23 18:03 AdamTyler

Yes it still happens for me on the latest version. Tried changing the rollDone callback to parenthesis as @The1Percent suggested but didn't help. Also tested on a blank project and get the same.

timB73 avatar Mar 22 '23 22:03 timB73

@timB73 I see what you are saying...

Whats happening is the library is building the die and then applying the rotation animation to make sure the initial value is facing up.

I will try and think of a way around this

AdamTyler avatar Mar 23 '23 19:03 AdamTyler

Hello, just wondering if there are any updates on this? It would be great if this could get fixed.

timB73 avatar May 07 '23 15:05 timB73

Hey Tim,

I can’t write code outside of my current role without conflict of interest review and approval. Maybe one of the other team members can assist.

Thanks,

Shane

From: Tim Bartrum @.> Sent: Sunday, May 7, 2023 8:03 AM To: AdamTyler/react-dice-complete @.> Cc: The1Percent @.>; Mention @.> Subject: Re: [AdamTyler/react-dice-complete] Dice rolling automatically on render (#23)

Hello, just wondering if there are any updates on this? It would be great if this could get fixed.

— Reply to this email directly, view it on GitHub https://github.com/AdamTyler/react-dice-complete/issues/23#issuecomment-1537462499 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACE353B5DS7DZIULYPT4SJTXE62RVANCNFSM4PRUZBCA . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ACE353DRJGYEQYXC2C45RJ3XE62RVA5CNFSM4PRUZBCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOLOR5BYY.gif Message ID: @.*** @.***> >

The1Percent avatar May 07 '23 21:05 The1Percent

Hello, just to know if there is update ? I have the same issue

badidu09 avatar May 23 '23 20:05 badidu09

This issue has been fixed in v2.2.0

AdamTyler avatar Jun 12 '23 18:06 AdamTyler

Awesome thank you!

timB73 avatar Jun 12 '23 19:06 timB73

Hi, btw I still seem to be getting the same behaviour after upgrading to v2.2.0

timB73 avatar Jan 04 '24 22:01 timB73