JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1342
  • Score
    100M100P100Q103659F
  • License MIT

Hide/show a component's children

Package Exports

  • react-toggle-display

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-toggle-display) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-toggle-display

Build Status

A stateless react component that toggles the display of it's children. It's like ng-show or ng-hide but for react.

This allows you to DRY up statements liks this:

<div className={this.props.shouldHide ? 'hidden' : ''}>

Example usage:

import ToggleDisplay from 'react-toggle-display';

export default React.createClass({
    
    getInitialState() {
        return {
            isAuthorized: false
        };
    },

    render() {
        return (
            <ToggleDisplay show={this.state.isAuthorized}>
                <p>Secret stuff for authorized people only.</p>
            </ToggleDisplay>
        );
    }

});

[View demo](https://jsfiddle.net/ccnokes/oqttsu83/)

The component supports the hide or show props and expects a boolean for both.

Install

npm install react-toggle-display

Tests

To run tests:

npm test

Note that tests have to be run on node version 0.10. See https://github.com/facebook/jest/issues/243 for why.