Last active
May 12, 2017 14:57
-
-
Save Razzwan/9d8df96998cb1e71028ae0bbd5b54781 to your computer and use it in GitHub Desktop.
Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import PropTypes from 'prop-types' | |
import { View } from 'react-native' | |
class Component extends Component { | |
static propTypes = { | |
styles: PropTypes.object, | |
} | |
state = { | |
showAll: true, | |
} | |
componentWillMount () { | |
if (this.props.list.length === 0) { | |
this.props.onGetList() | |
} | |
} | |
handleButtonShowAllClick = (e) => { | |
this.setState({ showAll: !this.state.showAll }) | |
} | |
render () { | |
const { styles, list } = this.props | |
const { showAll } = this.state | |
return ( | |
<View style={styles.box}> | |
{sowAll && list.map(item => ( | |
<Text>{item.name}</Text> | |
))} | |
<Text style={styles.description}>Description</Text> | |
<Button onClick={this.handleButtonShowAllClick}>Show all toggle</Button> | |
</View> | |
) | |
} | |
} | |
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { connect } from 'react-redux' | |
import Component from './Component' | |
import styles from './styles' | |
export default connect( | |
store => ({ | |
styles: styles, | |
}) | |
)(Component) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import colors from 'styles/palette' | |
const styles = { | |
box: { | |
backgroundColor: colors.baseColor, | |
}, | |
text: { | |
color: colors.secondColor, | |
}, | |
} | |
export default styles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All this files located in a single folder with name
Component