@pvinis/react-conditional-wrap
v1.0.1
Published
A simple component that helps you easily wrap components with other components, contidionally.
Downloads
16
Readme
react-conditional-wrap
A simple component that helps you easily wrap components with other components, contidionally.
Installation
npm install react-conditional-wrap
Usage
- Anything inside
Wrap.Content
will always be rendered. - Anything between
Wrap
andWrap.Content
will only be rendered if theif
prop istrue
.
import { Wrap } from 'react-conditional-wrap'
function MyComponent() {
const [show, setShow] = useState(true)
return (
<Wrap if={show}>
<div style={{ backgroundColor: "pink" }}>
<Wrap.Content>
<div>Hello World</div>
</Wrap.Content>
</div>
</Wrap>
)
}