mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
20 lines
No EOL
614 B
JavaScript
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); |