Skip to content

Commit ca6df6a

Browse files
committed
feat: add solution for react native version of simple counter challenge
1 parent 51a1e07 commit ca6df6a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React, { useState } from "react"
2+
import { Text, View, StyleSheet } from "react-native"
3+
4+
const SimpleCounter = () => {
5+
const [count, setCount] = useState(0)
6+
7+
const increment = () => setCount(count + 1)
8+
return (
9+
<View style={styles.container}>
10+
<Text style={styles.counter}>
11+
button count: <span id="actualCount">{count}</span>
12+
</Text>
13+
<button id="mainButton" onClick={increment}>
14+
INCREASE
15+
</button>
16+
</View>
17+
)
18+
}
19+
20+
const styles = StyleSheet.create({
21+
container: {
22+
flex: 1,
23+
justifyContent: "center",
24+
marginHorizontal: 10,
25+
},
26+
counter: {
27+
textAlign: "center",
28+
marginVertical: 10,
29+
},
30+
})
31+
32+
export default SimpleCounter

0 commit comments

Comments
 (0)