Skip to content
This repository was archived by the owner on Jan 8, 2021. It is now read-only.

Commit 1880986

Browse files
author
andela-akhenda
committed
feat(redux): wire up redux
1 parent 30cadcd commit 1880986

File tree

2 files changed

+26
-82
lines changed

2 files changed

+26
-82
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'src/config/reactotron';
12
import { AppRegistry } from 'react-native';
23
import App from './src/App';
34

src/App.js

Lines changed: 25 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,37 @@
1-
/**
2-
* Sample React Native App
3-
* https://github.com/facebook/react-native
4-
* @flow
5-
*/
6-
1+
import 'src/config';
72
import React, { Component } from 'react';
8-
import {
9-
Platform,
10-
StyleSheet,
11-
Text,
12-
View,
13-
TextInput,
14-
} from 'react-native';
15-
16-
import Child from './Child';
3+
import { View, Image, StatusBar } from 'react-native';
4+
import { Provider } from 'react-redux';
5+
import { PersistGate } from 'redux-persist/es/integration/react';
176

18-
const instructions = Platform.select({
19-
ios: 'Press Cmd+R to reload,\n' +
20-
'Cmd+D or shake for dev menu',
21-
android: 'Double tap R on your keyboard to reload,\n' +
22-
'Shake or press menu button for dev menu',
23-
});
7+
import { store, persistor } from 'src/state';
8+
import { images, colors } from './theme';
9+
import styles from './theme/styles';
10+
import RootContainer from './containers/RootContainer';
11+
import LoadingIndicator from './components/LoadingIndicator';
2412

25-
export default class App extends Component<{}> {
26-
constructor(props) {
27-
super(props);
28-
this.state = { text: '' };
29-
}
3013

31-
setText(text) {
32-
this.setState({ text });
33-
}
34-
35-
handleTextChange(text) {
36-
this.setText(text);
37-
}
38-
39-
clearText() {
40-
this.setText('');
14+
class App extends Component {
15+
onBeforeLift = () => {
16+
// take some action before the gate lifts
4117
}
4218

4319
render() {
44-
const { text } = this.state;
45-
4620
return (
47-
<View testID='Welcome' style={styles.container}>
48-
<Text testID='WelcomeTitle' style={styles.welcome}>
49-
Welcome to React Native!
50-
</Text>
51-
<Text testID='WelcomeInstruction' style={styles.instructions}>
52-
To get started, edit App.js
53-
</Text>
54-
<Text testID='Instructions' style={styles.instructions}>
55-
{instructions}
56-
</Text>
57-
<TextInput
58-
value={text}
59-
testID='TextInput'
60-
style={styles.input}
61-
placeholder={'Write something...'}
62-
onChangeText={txt => this.handleTextChange(txt)}
63-
/>
64-
<Child text={text} onClear={() => this.clearText()} />
65-
</View>
21+
<Provider store={store}>
22+
<PersistGate
23+
loading={<LoadingIndicator />}
24+
onBeforeLift={this.onBeforeLift}
25+
persistor={persistor}>
26+
<View style={styles.mainContainer}>
27+
<StatusBar translucent barStyle="light-content" backgroundColor={colors.statusBarTranslucent} />
28+
<Image source={images.background} style={styles.backgroundImage} />
29+
<RootContainer />
30+
</View>
31+
</PersistGate>
32+
</Provider>
6633
);
6734
}
6835
}
6936

70-
const styles = StyleSheet.create({
71-
container: {
72-
flex: 1,
73-
justifyContent: 'center',
74-
alignItems: 'center',
75-
backgroundColor: '#F5FCFF',
76-
},
77-
welcome: {
78-
fontSize: 20,
79-
textAlign: 'center',
80-
margin: 10,
81-
},
82-
instructions: {
83-
textAlign: 'center',
84-
color: '#333333',
85-
marginBottom: 5,
86-
},
87-
input: {
88-
width: '80%',
89-
height: 60,
90-
padding: 10,
91-
marginTop: 30,
92-
alignSelf: 'center',
93-
},
94-
});
37+
export default App;

0 commit comments

Comments
 (0)