fix(know-your-world): guard against undefined state during session init

Add loading guard in GameComponent to prevent crash when state is
undefined during session initialization.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-11-30 15:04:37 -06:00
parent 60cf98e77a
commit ea8965bc95
1 changed files with 17 additions and 0 deletions

View File

@ -27,6 +27,23 @@ export function GameComponent() {
return () => window.removeEventListener(CROP_MODE_EVENT, handleCropModeChange)
}, [])
// Guard against undefined state during session initialization
if (!state) {
return (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
color: '#888',
}}
>
Loading...
</div>
)
}
// Determine current player for turn indicator (if turn-based mode)
const currentPlayerId =
state.gamePhase === 'playing' && state.gameMode === 'turn-based'