From 4a358d04b18f3c71c0d76e3d884931945699a703 Mon Sep 17 00:00:00 2001 From: zihao Date: Wed, 7 Feb 2024 12:35:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20tile=20re-render?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/game/GameMap.tsx | 24 ++++++++++++------------ client/components/game/MapTile.tsx | 5 +---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/client/components/game/GameMap.tsx b/client/components/game/GameMap.tsx index df1f88e..d40c171 100644 --- a/client/components/game/GameMap.tsx +++ b/client/components/game/GameMap.tsx @@ -50,7 +50,7 @@ function GameMap() { }; const { setSelectedMapTileInfo, halfArmy, clearQueue, popQueue, selectGeneral, - + handlePositionChange, testIfNextPossibleMove, handleClick, attackUp, attackDown, attackLeft, attackRight } = useGameDispatch(); @@ -373,17 +373,17 @@ function GameMap() { {displayMapData.map((tiles, x) => { return tiles.map((tile, y) => { return ( - handleClick(tile.tile, x, y, myPlayerIndex)} - // handleClick={() => { }} - key={`${x}/${y}`} - zoom={zoom} - size={tileSize} - x={x} - y={y} - {...tile} - warringStatesMode={room.warringStatesMode} /> +
handleClick(tile.tile, x, y, myPlayerIndex)}> + +
); }); })} diff --git a/client/components/game/MapTile.tsx b/client/components/game/MapTile.tsx index 90f7bc2..b35ff77 100644 --- a/client/components/game/MapTile.tsx +++ b/client/components/game/MapTile.tsx @@ -28,7 +28,6 @@ interface MapTileProps { isSelected: boolean; isNextPossibleMove: boolean; warringStatesMode: boolean; - handleClick: () => void; } export default React.memo(function MapTile(props: MapTileProps) { @@ -46,9 +45,8 @@ export default React.memo(function MapTile(props: MapTileProps) { isSelected, isNextPossibleMove, warringStatesMode = false, - handleClick } = props; - // console.log(`${x} ${y} render`, new Date().toISOString()); + console.log(`${x} ${y} render`, new Date().toISOString()); const [cursorStyle, setCursorStyle] = useState('default'); const [tileType, color, unitsCount] = tile; @@ -151,7 +149,6 @@ export default React.memo(function MapTile(props: MapTileProps) { }} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} - onClick={handleClick} >