avaneeshtripathi / react-dice-roll

A highly customizable dice roll package built in react.
https://www.npmjs.com/package/react-dice-roll
36 stars 23 forks source link

External dice roll triggers #9

Closed ianleblancbomb closed 1 year ago

ianleblancbomb commented 2 years ago

Not an issue per say but would be nice to trigger dice roll externally from clicking on dice so multiple dice on screen can all be triggered at once.

Rakeshpradhan1999 commented 2 years ago

I also want this function

avaneeshtripathi commented 2 years ago

@ianleblancbomb @Rakeshpradhan1999 To achieve this, You can pass refs to the dice components, and use that ref to trigger the dice roll

Ex: diceRef.rollDice()

this method can be used, its not typescripted though. But it does work.

for multiple dices, you can pass refs to all the dices and then trigger rollDice for all of them.