Skip to content

Commit

Permalink
Trick React into thinking a container is a class
Browse files Browse the repository at this point in the history
Summary:
The factory component pattern is about to be deprecate in:

facebook/react#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
  • Loading branch information
sebmarkbage authored and facebook-github-bot committed Mar 19, 2019
1 parent 47d676d commit ffbe17b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-relay/buildReactRelayContainer.js
Expand Up @@ -71,6 +71,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<*>>(
// $FlowFixMe
return new Container(props);
}
ContainerConstructor.prototype = React.Component.prototype;

function forwardRef(props, ref) {
const context = readContext(ReactRelayContext);
Expand Down

0 comments on commit ffbe17b

Please sign in to comment.