withInjected -> PureComponent (fix new refs) (#1195)
* withInjected -> PureComponent (fix new refs) * Consume data from context * Expand injected
This commit is contained in:
parent
fb8b2bf20c
commit
cb522a4263
@ -27,18 +27,19 @@ export {
|
||||
};
|
||||
|
||||
export function withInjected<P extends ApiInjectedProps> (Component: React.ComponentType<P>): React.ComponentType<Subtract<P, ApiInjectedProps>> {
|
||||
return (props: Subtract<P, ApiInjectedProps>) => {
|
||||
return (
|
||||
<InjectedContext.Consumer>
|
||||
{(injected) => (
|
||||
// @ts-ignore Something here with the props are going wonky
|
||||
<Component
|
||||
{...props}
|
||||
injectedAvailable={injectedAvailable}
|
||||
injectedPromise={injectedPromise}
|
||||
/>
|
||||
)}
|
||||
</InjectedContext.Consumer>
|
||||
);
|
||||
return class extends React.PureComponent<Subtract<P, ApiInjectedProps>> {
|
||||
render () {
|
||||
return (
|
||||
<InjectedContext.Consumer>
|
||||
{(injected) => (
|
||||
// @ts-ignore Something here with the props are going wonky
|
||||
<Component
|
||||
{...this.props}
|
||||
{...injected}
|
||||
/>
|
||||
)}
|
||||
</InjectedContext.Consumer>
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user