All files / src/components root.js

100% Statements 11/11
50% Branches 1/2
100% Functions 1/1
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x 1x   1x 1x     21x   7x 7x       12x               12x       1x       1x          
import React from 'react';
import PropTypes from 'prop-types';
 
import { storeKey, streamKey, subscriptionKey } from '../constants';
import { storeShape, subscriptionShape } from '../connect/utils/PropTypes';
 
export class Root extends React.Component {
  constructor(props, context) {
    super(props, context);
    this[storeKey] = props.store;
    this[streamKey] = props.tanokStream;
  }
 
  getChildContext() {
    return {
      [storeKey]: this[storeKey],
      [streamKey]: this[streamKey],
      [subscriptionKey]: null,
    }
  }
 
  render() {
    return React.Children.only(this.props.children);
  }
}
 
Root.propTypes = {
    store: storeShape.isRequired,
    children: PropTypes.element.isRequired,
};
Root.childContextTypes = {
    [storeKey]: storeShape.isRequired,
    [streamKey]: PropTypes.any.isRequired,
    [subscriptionKey]: subscriptionShape,
};