Last active
February 24, 2020 03:38
-
-
Save BrooklinJazz/24aef5beebab825b07b4c19e232de5a2 to your computer and use it in GitHub Desktop.
App with Working Start Button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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