All files / src throughInterface.js

50% Statements 3/6
0% Branches 0/2
40% Functions 2/5
40% Lines 2/5
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      2x                                           2x        
import React, { Children } from 'react'
import PropTypes from 'prop-types'
 
const throughInterface = (area) => (AgentComponent) => {
  class ThroughInterface extends React.Component {
    static contextTypes = {
      through: PropTypes.object,
    }
 
    render() {
      return (
        <AgentComponent {...this.props}
          { ...{[area]: {
            install: (key, props, syncUpdate = undefined) => {
              this.context.through.install(area, key, props, syncUpdate)
            },
            remove: (key, syncUpdate = undefined) => {
              this.context.through.remove(area, key, syncUpdate)
            },
          } } }
       />
      )
    }
  }
 
  return ThroughInterface
}
 
export default throughInterface