Fix: Resolver error de React hooks en fase MISSION
- Mover useState de cardOrder al nivel del componente - Eliminar IIFE que causaba violación de reglas de hooks - Usar cardOrder directamente en lugar de successFirst - Ahora la fase MISSION debería funcionar correctamente
This commit is contained in:
@@ -15,6 +15,10 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
|
|||||||
// Hooks para FASE REVEAL ROLE
|
// Hooks para FASE REVEAL ROLE
|
||||||
const [revealCard, setRevealCard] = useState(false);
|
const [revealCard, setRevealCard] = useState(false);
|
||||||
|
|
||||||
|
// Orden aleatorio de cartas de misión (se genera una vez)
|
||||||
|
const [cardOrder] = useState(() => Math.random() > 0.5);
|
||||||
|
|
||||||
|
|
||||||
// Timer para avanzar automáticamente en REVEAL_ROLE
|
// Timer para avanzar automáticamente en REVEAL_ROLE
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (gameState.phase === 'reveal_role' as any) {
|
if (gameState.phase === 'reveal_role' as any) {
|
||||||
@@ -463,18 +467,14 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
|
|||||||
) : (
|
) : (
|
||||||
<div className="text-white text-xl font-mono animate-pulse">
|
<div className="text-white text-xl font-mono animate-pulse">
|
||||||
VOTO REGISTRADO. ESPERANDO AL RESTO...
|
VOTO REGISTRADO. ESPERANDO AL RESTO...
|
||||||
|
```
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* FASE: MISIÓN */}
|
{/* FASE: MISIÓN */}
|
||||||
{gameState.phase === GamePhase.MISSION && (() => {
|
{gameState.phase === GamePhase.MISSION && (
|
||||||
// Generar orden aleatorio de cartas (solo una vez por jugador)
|
|
||||||
const [cardOrder] = useState(() => Math.random() > 0.5);
|
|
||||||
const successFirst = cardOrder;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<motion.div
|
<motion.div
|
||||||
key="mission"
|
key="mission"
|
||||||
className="fixed inset-0 flex items-center justify-center bg-black/90 z-50"
|
className="fixed inset-0 flex items-center justify-center bg-black/90 z-50"
|
||||||
@@ -497,7 +497,7 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
|
|||||||
|
|
||||||
{/* Cartas en orden aleatorio */}
|
{/* Cartas en orden aleatorio */}
|
||||||
<div className="flex gap-12 flex-wrap justify-center">
|
<div className="flex gap-12 flex-wrap justify-center">
|
||||||
{successFirst ? (
|
{cardOrder ? (
|
||||||
<>
|
<>
|
||||||
{/* Carta de Éxito primero */}
|
{/* Carta de Éxito primero */}
|
||||||
<button onClick={() => actions.voteMission(true)} className="group">
|
<button onClick={() => actions.voteMission(true)} className="group">
|
||||||
@@ -564,8 +564,7 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
)}
|
||||||
})()}
|
|
||||||
|
|
||||||
{/* FASE: REVELACIÓN DE CARTAS */}
|
{/* FASE: REVELACIÓN DE CARTAS */}
|
||||||
{gameState.phase === 'mission_reveal' as any && (
|
{gameState.phase === 'mission_reveal' as any && (
|
||||||
|
|||||||
Reference in New Issue
Block a user