How to use the inferno-compat.PropTypes function in inferno-compat

To help you get started, we’ve selected a few inferno-compat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infernojs / inferno / packages / inferno-compat / __tests__ / ReactComponent.spec.jsx View on Github external
it('should pass context to children when not owner', function() {
    var Parent = React.createClass({
      render: function() {
        return (
          
            
          
        );
      }
    });

    var Child = React.createClass({
      childContextTypes: {
        foo: React.PropTypes.string
      },

      getChildContext: function() {
        return {
          foo: 'bar'
        };
      },

      render: function() {
        return React.Children.only(this.props.children);
      }
    });

    var Grandchild = React.createClass({
      contextTypes: {
        foo: React.PropTypes.string
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactES6Class.spec.jsx View on Github external
it('supports this.context passed via getChildContext', function() {
    class Bar extends React.Component {
      render() {
        return <div>;
      }
    }
    Bar.contextTypes = { bar: React.PropTypes.string };
    class Foo extends React.Component {
      getChildContext() {
        return { bar: 'bar-through-context' };
      }
      render() {
        return ;
      }
    }
    Foo.childContextTypes = { bar: React.PropTypes.string };
    test(, 'DIV', 'bar-through-context');
  });
</div>
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactClass.spec.jsx View on Github external
it('renders based on context getInitialState', function() {
    var Foo = React.createClass({
      contextTypes: {
        className: React.PropTypes.string
      },
      getInitialState() {
        return { className: this.context.className };
      },
      render() {
        return <span>;
      }
    });

    var Outer = React.createClass({
      childContextTypes: {
        className: React.PropTypes.string
      },
      getChildContext() {
        return { className: 'foo' };
      },</span>
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactClass.spec.jsx View on Github external
it('renders based on context getInitialState', function() {
    var Foo = React.createClass({
      contextTypes: {
        className: React.PropTypes.string
      },
      getInitialState() {
        return { className: this.context.className };
      },
      render() {
        return <span>;
      }
    });

    var Outer = React.createClass({
      childContextTypes: {
        className: React.PropTypes.string
      },
      getChildContext() {
        return { className: 'foo' };
      },
      render() {
        return ;
      }
    });

    var container = document.createElement('div');
    ReactDOM.render(, container);
    expect(container.firstChild.className).toBe('foo');
  });
</span>
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactES6Class.spec.jsx View on Github external
it('renders based on context in the constructor', function() {
    class Foo extends React.Component {
      constructor(props, context) {
        super(props, context);

        this.state = { tag: context.tag, className: this.context.className };
      }
      render() {
        var Tag = this.state.tag;
        return ;
      }
    }
    Foo.contextTypes = {
      tag: React.PropTypes.string,
      className: React.PropTypes.string
    };

    class Outer extends React.Component {
      getChildContext() {
        return { tag: 'span', className: 'foo' };
      }
      render() {
        return ;
      }
    }
    Outer.childContextTypes = {
      tag: React.PropTypes.string,
      className: React.PropTypes.string
    };
    test(, 'SPAN', 'foo');
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactComponent.spec.jsx View on Github external
},

      getChildContext: function() {
        return {
          foo: 'bar'
        };
      },

      render: function() {
        return React.Children.only(this.props.children);
      }
    });

    var Grandchild = React.createClass({
      contextTypes: {
        foo: React.PropTypes.string
      },

      render: function() {
        return <div>{this.context.foo}</div>;
      }
    });

    var component = renderIntoDocument();
    expect(ReactDOM.findDOMNode(component).innerHTML).toBe('bar');
  });
});