Skip to content

Instantly share code, notes, and snippets.

@dvas0004
Last active Dec 14, 2018
Embed
What would you like to do?
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { connect } from 'react-redux';
import {
testAction,
} from './redux';
import { Provider } from 'react-redux';
import { store } from './redux';
class AppInner extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text>Changes you make will automatically reload.</Text>
<Button onPress={this.props.testAction}>Test</Button>
<Text> {this.props.content}</Text>
</View>
);
}
}
export default class App extends React.Component {
render() {
return (
<Provider store={store}>
<AppContainer />
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
// AppContainer.js
const mapStateToProps = (state) => ({
content: state.dvas0004.content || "Please Wait...",
});
const mapDispatchToProps = (dispatch) => {
return {
testAction: () => {
dispatch(testAction())
}
}
};
const AppContainer = connect(
mapStateToProps,
mapDispatchToProps
)(AppInner);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment