-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
47 lines (37 loc) · 1.1 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import { StyleSheet, Text, View,Button } from 'react-native';
import Header from './Components/Header.js'
import StartGameScreen from './Screens/StartGameScreen'
import GameScreen from './Components/GameScreen'
import GameOverScreen from './Screens/GameOverScreen'
export default function App() {
const [userNumber,setUserNumber] = React.useState();
const [guessRounds, setGuessRounds] = React.useState(0)
const GameoverHandler = rounds => {
setGuessRounds(rounds)
}
const startGameHandler = selectedNumber =>{
setUserNumber(selectedNumber)
setGuessRounds(0)
}
let content = <StartGameScreen onStartGame={startGameHandler} />;
if(userNumber && guessRounds <= 0){
content = <GameScreen userChoice={userNumber} onGameOver = {GameoverHandler} />;
}
else if(guessRounds > 0){
content = <GameOverScreen rounds = {guessRounds}/>
}
return (
<View style={styles.container}>
<View>
<Header title="Guess Game" />
{content}
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
// flex:1,
},
});