Skip to content

Instantly share code, notes, and snippets.

View vicsstar's full-sized avatar

Victor Igbokwe vicsstar

View GitHub Profile
@dsheiko
dsheiko / If.jsx
Last active January 19, 2019 22:47
Renders React components conditionally e.g. <If exp={ true }></If> to avoid inline short-circuit evaluation/ternary hell
/*
Usage:
<If exp={ true }> components to render </If>
<If exp={ false }> components not to render </If>
*/
import React from "react";
import PropTypes from "prop-types";
export default class If extends React.Component {