-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
57 lines (53 loc) · 1.22 KB
/
Copy pathApp.tsx
File metadata and controls
57 lines (53 loc) · 1.22 KB
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
48
49
50
51
52
53
54
55
56
57
import { StyleSheet, Text, View, Button } from 'react-native';
import React from 'react';
import { Provider, useSelector, useDispatch } from 'react-redux';
import store, { State } from './store/store';
import { decrement, increment } from './store/counter.reducer';
export default function App() {
return (
<Provider store={store}>
<Counter />
</Provider>
);
}
function Counter() {
const counter = useSelector((state: State) => state.counter);
const dispatch = useDispatch();
return (
<View style={styles.container}>
<Text style={styles.text}>
Counter: {counter}
</Text>
<View style={styles.button}>
<Button
title='Increment'
onPress={() => dispatch(increment())}
/>
<Button
title='Decrement'
onPress={() => dispatch(decrement())}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
paddingTop: 300
},
text: {
fontSize: 32,
fontWeight: 'bold',
color: 'red',
marginBottom: 50,
},
button: {
flexDirection: 'row',
justifyContent: 'space-around',
width: 300,
height: 50
}
});