Vulcan/packages/nova-core/lib/modules/components/ShowIf.jsx
2017-02-06 22:24:05 +08:00

21 lines
No EOL
656 B
JavaScript

import { registerComponent } from 'meteor/nova:lib';
import React, { PropTypes } from 'react';
import withCurrentUser from '../containers/withCurrentUser.js';
const ShowIf = props => {
const { check, document, failureComponent = null, currentUser, children } = props;
return check(currentUser, document) ? children : failureComponent;
};
ShowIf.propTypes = {
check: React.PropTypes.func.isRequired,
currentUser: React.PropTypes.object,
document: React.PropTypes.object,
failureComponent: React.PropTypes.object,
};
ShowIf.displayName = "ShowIf";
registerComponent('ShowIf', ShowIf, withCurrentUser);
export default withCurrentUser(ShowIf);