AdamTyler / react-dice-complete

Complete dice rolling functionality and animations
http://adam-tyler.com/react-dice-complete
ISC License
79 stars 26 forks source link

Dice rolling automatically on render #23

Closed timB73 closed 1 year ago

timB73 commented 4 years ago

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 commented 4 years ago

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.

The1Percent commented 4 years ago

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

joey-carlisle4 commented 3 years ago

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

AdamTyler commented 1 year ago

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

timB73 commented 1 year ago

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.

AdamTyler commented 1 year ago

@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

timB73 commented 1 year ago

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

The1Percent commented 1 year ago

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: @. @.> >

badidu09 commented 1 year ago

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

AdamTyler commented 1 year ago

This issue has been fixed in v2.2.0

timB73 commented 1 year ago

Awesome thank you!

timB73 commented 10 months ago

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