From 6386b832a68a9a05a5ff2d6254728e85ba45b730 Mon Sep 17 00:00:00 2001 From: Thomas Rampelberg Date: Tue, 29 May 2018 17:11:40 -0700 Subject: [PATCH] Wrap withREST in context for api reference (#1036) As part of the HOC + Context merges, ResourceList missed out on the api injection and errors out on the Namespaces tab. Wrap the returned HOC in `withContext` to make sure it is there, no matter where it is in the tree. (Fixes #1034) --- web/app/js/components/util/withREST.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/app/js/components/util/withREST.jsx b/web/app/js/components/util/withREST.jsx index 9fa4e5535..9a8d0edce 100644 --- a/web/app/js/components/util/withREST.jsx +++ b/web/app/js/components/util/withREST.jsx @@ -1,5 +1,6 @@ import _ from 'lodash'; import React from 'react'; +import { withContext } from './AppContext.jsx'; /** * Provides components with data fetched via. polling a list of REST URLs. @@ -9,7 +10,7 @@ import React from 'react'; * @param {List[string]} resetProps - Props that on change cause a state reset. */ const withREST = (WrappedComponent, componentPromises, resetProps = []) => { - return class extends React.Component { + class RESTWrapper extends React.Component { constructor(props) { super(props); this.api = this.props.api; @@ -95,7 +96,9 @@ const withREST = (WrappedComponent, componentPromises, resetProps = []) => { {...this.props} /> ); } - }; + } + + return withContext(RESTWrapper); }; export default withREST;