Last active
March 16, 2017 17:37
-
-
Save pramendra/ed69fc366c369b0946940bb9a194ce96 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { PropTypes } from 'react'; | |
import { View } from 'react-native'; | |
const Renderer = (props) => { | |
if (props.isRefreshed === false) return props.loadingComponent; | |
return ( | |
<View style={{ flex: 1 }}> | |
{(props.isRefreshed && props.isZeroState === true) | |
? props.zeroStateComponent : props.children} | |
</View> | |
); | |
}; | |
Renderer.propTypes = { | |
isRefreshed: PropTypes.bool, | |
isZeroState: PropTypes.bool, | |
loadingComponent: PropTypes.node, | |
zeroStateComponent: PropTypes.node, | |
children: PropTypes.node, | |
}; | |
export default Renderer; | |
// ../components/MyProfile | |
<Renderer | |
isRefreshed={this.props.profileIsRefreshed} | |
loadingComponent={<Loading />} | |
isZeroState={!lodash.has(this.props.profile, 'id')} | |
zeroStateComponent={<Loading />} | |
> | |
<MyProfile | |
profile={this.props.profile} | |
badgeCount={this.props.badgeCountByAction} | |
/> | |
</Renderer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment