React Conditional Rendering
React-Conditional-Rendering is a React based utitly that helps you do conditional renderings in components.
- Do npm install react-conditional-rendering
- Import a component you need
- See magic
Installation
Install the dependencies and devDependencies and start the server.
$ cd porject$ npm install react-conditional-rendering$ npm start
Usage
import React from 'react';import RenderIf RenderComponent from 'react-conditional-rendering'; Component state = buttonPressed: false renderDummyComponent: false ; <div = > <p>This component only render if the render component is checked</p> </div> ; { const buttonPressed = false renderDummyComponent = false } = thisstate; return <div> <RenderIf => <div => Rendering with children </div> </RenderIf> <RenderComponent = = /> <button = > First Example </button> <button = > Second Example </button> </div> ; }