No longer works, please transform to react-tag
https://www.npmjs.com/package/react-tag
React Div
Like the normal HTML <div/>
but useful.
Why?
When you want to show or hide a div, you probably do this everytime:
{ const style = display: show ? '' : 'none' return <div style=style /> }
And we always dynamically add
or remove
classes inconvenient.
or using the JedWatson/classnames
const classNames = { const css = foo: true bar: false return <div className=`a b c ` /> }
Today you can stop doing that. React Div
is your new friend.
Default Props
static propTypes = css: PropTypesobject style: PropTypesobject show: PropTypes hide: PropTypes className: PropTypesstring static defaultProps = css: {} style: {} show: true hide: false className: ''
Examples
show: dynamically show the div
const Div = { return <Div show=false style=color: 'red'>This is Dev Component</Div>}
output:
This is Dev Component
css: dynamically toggle css classes
const Div = const css = foo: true bar: false { return <Div className="a b" css=css />}
output:
hide: dynamically hide the div
Sometime we don't want to render DOM, you can hide it by passing a hide
props:
const Div = { return <Div hide=true />}
output nothing: