From a585cbb0039e9072e80f37c46acd3cc5065e628b Mon Sep 17 00:00:00 2001 From: David Buchan-Swanson Date: Tue, 10 Oct 2017 00:05:21 +1000 Subject: [PATCH] hoist non-react static methods in decorator (#1037) --- CodePush.js | 5 ++++- package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CodePush.js b/CodePush.js index cf00231..235abc1 100644 --- a/CodePush.js +++ b/CodePush.js @@ -4,6 +4,7 @@ import requestFetchAdapter from "./request-fetch-adapter"; import { AppState, Platform } from "react-native"; import RestartManager from "./RestartManager"; import log from "./logging"; +import hoistStatics from 'hoist-non-react-statics'; let NativeCodePush = require("react-native").NativeModules.CodePush; const PackageMixins = require("./package-mixins")(NativeCodePush); @@ -451,7 +452,7 @@ function codePushify(options = {}) { } var decorator = (RootComponent) => { - return class CodePushComponent extends React.Component { + const extended = class CodePushComponent extends React.Component { componentDidMount() { if (options.checkFrequency === CodePush.CheckFrequency.MANUAL) { CodePush.notifyAppReady(); @@ -503,6 +504,8 @@ function codePushify(options = {}) { return } } + + return hoistStatics(extended, RootComponent); } if (typeof options === "function") { diff --git a/package.json b/package.json index 3a734bd..ce31698 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "dependencies": { "code-push": "1.11.2-beta", "glob": "^5.0.15", + "hoist-non-react-statics": "^2.3.1", "inquirer": "1.1.2", "plist": "1.2.0", "xcode": "0.9.2"