react-allowed
v1.1.0
Published
a react component that calls a function prop isAllowed to determine whether or not to render children
Downloads
7
Maintainers
Readme
React Allowed
a react component that calls a function prop isAllowed to determine whether or not to render children
Install
npm install react-allowed --save
Use
props
isAllowed
- a functiont that returns true or false. receives arguments via .apply from the isAllowedArgs props.isAllowedArgs
- array of arguments to be passed to isAllowed via .applychildren
- a single element to be child to be shown if isAllowed returns truenotAllowedElement
- what to show if isAllowed() returns false, defaults to nothing.
import Allowed from 'react-allowed';
const Component = () => {
return (
<Allowed
isAllowed={num => num > 5}
isAllowedArgs={[7]}
notAllowedElement={<div>number too low</div>}
/>
<h1>wow what a big number</h1>
</Allowed>
}
License
MIT