(name, type = PropTypes.any.isRequired)
| 2 | import React from "react"; |
| 3 | |
| 4 | export default function context(name, type = PropTypes.any.isRequired) { |
| 5 | return function contextDecorator(Component) { |
| 6 | class ContextDecorator extends React.Component { |
| 7 | static contextTypes = { |
| 8 | [name]: type, |
| 9 | } |
| 10 | |
| 11 | static displayName = "ContextDecorator" |
| 12 | |
| 13 | render() { |
| 14 | return <Component {...this.context} {...this.props} />; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | return ContextDecorator; |
| 19 | }; |
| 20 | } |
no outgoing calls
no test coverage detected