From ffbe17b046e0d26d9280c4bd5f9d45deeb7de784 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Tue, 19 Mar 2019 13:18:44 -0700 Subject: [PATCH] Trick React into thinking a container is a class Summary: The factory component pattern is about to be deprecate in: https://github.com/facebook/react/pull/15145 This change makes it so that React will call this constructor with `new` as if it is a class component instead of just calling it as a function component. There might be a slight perf penalty to doing this my understanding is that this is not the preferred path anyway. Reviewed By: kassens Differential Revision: D14516681 fbshipit-source-id: 751890a98639687b208633f2e4c8e71e5df60776 --- packages/react-relay/buildReactRelayContainer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-relay/buildReactRelayContainer.js b/packages/react-relay/buildReactRelayContainer.js index 0af892a567c43..6805cdf836590 100644 --- a/packages/react-relay/buildReactRelayContainer.js +++ b/packages/react-relay/buildReactRelayContainer.js @@ -71,6 +71,7 @@ function buildReactRelayContainer>( // $FlowFixMe return new Container(props); } + ContainerConstructor.prototype = React.Component.prototype; function forwardRef(props, ref) { const context = readContext(ReactRelayContext);