Skip to content

Instantly share code, notes, and snippets.

@dvas0004
Last active December 14, 2018 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvas0004/b1d9d236661d2b77ebdc59774064ea27 to your computer and use it in GitHub Desktop.
Save dvas0004/b1d9d236661d2b77ebdc59774064ea27 to your computer and use it in GitHub Desktop.
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