Vulcan/packages/vulcan-core/lib/modules/components/ShowIf.jsx
2018-09-16 11:48:38 +09:00

20 lines
No EOL
614 B
JavaScript

import { registerComponent } from 'meteor/vulcan:lib';
import React from 'react';
import PropTypes from 'prop-types';
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: PropTypes.func.isRequired,
currentUser: PropTypes.object,
document: PropTypes.object,
failureComponent: PropTypes.object,
};
ShowIf.displayName = 'ShowIf';
registerComponent('ShowIf', ShowIf, withCurrentUser);