mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 08:54:45 +08:00
27 lines
682 B
JavaScript
27 lines
682 B
JavaScript
import React from 'react';
|
|
import hoistStatics from 'recompose/hoistStatics';
|
|
import { Subscriber } from 'react-broadcast';
|
|
import get from 'lodash/get';
|
|
|
|
/**
|
|
* WithVariables provides a property `variables` to the wrapped component.
|
|
* These are the variables of the parent Query.
|
|
*/
|
|
export default hoistStatics(WrappedComponent => {
|
|
class WithVariables extends React.Component {
|
|
render() {
|
|
return (
|
|
<Subscriber channel="queryData">
|
|
{data => (
|
|
<WrappedComponent
|
|
{...this.props}
|
|
variables={get(data, 'variables')}
|
|
/>
|
|
)}
|
|
</Subscriber>
|
|
);
|
|
}
|
|
}
|
|
return WithVariables;
|
|
});
|