Is this possible? I’m trying to deal cards from an array to start a game, but everything I try is just dealing the first card over and over again. React batches the updates, so the array is changed only after the loop completes. Everything says use the callback method, which seems to be the only way in ReScript, but it still isn’t updating the state before the next iteration such that subsequent cards would be dealt out. I had a ‘deal’ button that calls a deal func when clicked that runs a for loop up to the number of players, calling ‘setDeck’ each time, deck being the result of sliceToEnd
, which returns a new array: setDeck(_ => Array.sliceToEnd(deck, ~start=1))
or setDeck(prev => Array.sliceToEnd(prev, ~start=1))
, etc. How can I do this?
Thank you!