Skip to content

Instantly share code, notes, and snippets.

@pramendra
Last active March 16, 2017 17:37
Show Gist options
  • Save pramendra/ed69fc366c369b0946940bb9a194ce96 to your computer and use it in GitHub Desktop.
Save pramendra/ed69fc366c369b0946940bb9a194ce96 to your computer and use it in GitHub Desktop.
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