react-x-render
Render React components conditionally using if and unless.
Getting Started
Install react-x-render
using yarn
:
yarn add react-x-render
Usage
;;;; Component // -------------------------------------------------- // Props // -------------------------------------------------- static propTypes = user: PropTypesobjectisRequired ; static defaultProps = ; // -------------------------------------------------- // Render // -------------------------------------------------- { const user = thisprops; return <View> <Render if=user> <Text>`Hi `</Text> </Render> <View> ... </View> <Render unless=user> <Text>`Receive $1,000,000 for free?`</Text> </Render> </View> ; }
Props
Prop | Type | Required | Description |
---|---|---|---|
if |
boolean | no | If this is true, it will render the child. |
unless |
boolean | no | If this is false, it will render the child. |
Contributing
If you have any ideas on how this module could be better, create an Issue or submit a PR.