From c416bf6664aee7728c6017842e01ca926d91d233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Szyd=C5=82owski?= <9szydlowski9@gmail.com> Date: Wed, 3 Jul 2024 13:40:28 +0200 Subject: [PATCH] Fix 2048 example (#6205) ## Summary 2048 example was crashing on web because of a function being referenced before being initialised. ## Test plan ![image](https://github.com/software-mansion/react-native-reanimated/assets/77503811/1b5ed7f8-1fe9-4d60-8442-b73b131f0bf8) --- apps/common-app/src/examples/Game2048Example.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/common-app/src/examples/Game2048Example.tsx b/apps/common-app/src/examples/Game2048Example.tsx index 229cc447f61..6ca5493e3d5 100644 --- a/apps/common-app/src/examples/Game2048Example.tsx +++ b/apps/common-app/src/examples/Game2048Example.tsx @@ -226,6 +226,11 @@ export default function Game2048Example() { const [tiles, setTiles] = React.useState(makeInitialBoard); const [gameOver, setGameOver] = React.useState(false); + const handleReset = React.useCallback(() => { + setTiles(makeInitialBoard()); + setGameOver(false); + }, []); + const fling = Gesture.Pan() .runOnJS(true) .onEnd((e) => { @@ -245,11 +250,6 @@ export default function Game2048Example() { } }); - const handleReset = React.useCallback(() => { - setTiles(makeInitialBoard()); - setGameOver(false); - }, []); - return (