Skip to content

Instantly share code, notes, and snippets.

@BrooklinJazz
Last active February 24, 2020 03:38
Show Gist options
  • Select an option

  • Save BrooklinJazz/24aef5beebab825b07b4c19e232de5a2 to your computer and use it in GitHub Desktop.

Select an option

Save BrooklinJazz/24aef5beebab825b07b4c19e232de5a2 to your computer and use it in GitHub Desktop.
App with Working Start Button
import React, {useState} from 'react'; // make sure to import useState
// rather than use magic strings like "playing" and "starting" I'm using an object for our gameState options.
const GameState = {
playing: "playing",
starting: "starting"
}
const Game = () => {
return (
<Text>The Game will be here</Text>
)
}
export default function App() {
const [gameState, setGameState] = useState(GameState.starting)
const startGame = () => setGameState(GameState.playing)
return (
<Container>
{gameState === GameState.starting && <SuccessButton onPress={startGame} >Start</SuccessButton>}
{gameState === GameState.playing && <Game/>}
</Container>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment