Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-fantasy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-fantasy

Renderers for stuctures from fantasyland project

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-fantasy

Rendering fantasyland structures in React.

Options

Option is a container for value, witch encapsulate null check condition. Allow replace null with Option.None and write only logic without any checks.

Usage

var React = require('react'),
    Option = require('fantasy-options').Option,
    option = require('react-fantasy').option;

var SomeValue = React.createClass({

    getDefaultProps : function () {
        return {
            value : Option.None;
        }
    },

    renderValue : function (value) {
        return (
            <span className="value">
                {value}
            </span>
        )
    }

    render : function () {
        return option(this.renderValue).render(this.props.value);
    }
});

var SomeContainer = React.createClass({

    getDefaultProps : function () {
        return {
            value : Option.of('Some string');
        }
    },

    render : function () {
        return (
            <div>
                <SomeValue />
                <SomeValue value={this.props.value} />
            </div>
        )
    }
})

Rendered as

<div>
    <noscript/>
    <span class="value">
        Some string
    </span>
</div>

Type checkers

Add check propTypes and contextTypes for fantasy structures such as Option, Seq and Json. In future will be added Either, Readers, Writers and State

PropTypes example:

var fpt = require('react-fantasy').PropTypes;

var SomeClass = React.createClass({
    ...
    propTypes : {
        page: fpt.option.isRequired,
        items: fpt.seq.isRequired,
        config: fpt.json.isRequired
    }
    ...
});

Whenever non required values is possible, but that non functional behavior, because before rendering need some checks for ensure what value is present.

License

MIT

Keywords

FAQs

Package last updated on 15 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc