jcgertig/react-pundit

View on GitHub
src/PunditTypeSet.js

Summary

Maintainability
A
0 mins
Test Coverage
import React, { Component, Children } from 'react';
import PropTypes from 'prop-types';

class PunditTypeSet extends Component {
  static displayName = 'PunditTypeSet';

  static propTypes = {
    type: PropTypes.string,
    model: PropTypes.any,
  };

  static defaultProps = {
    type: '',
    model: null,
  };

  static childContextTypes = {
    punditType: PropTypes.string,
    punditModel: PropTypes.any,
  };

  getChildContext() {
    return { punditType: this.props.type, punditModel: this.props.model };
  }

  render() {
    return this.props.children;
  }
}

export default PunditTypeSet;