Skip to content

Commit

Permalink
hoist non-react static methods in decorator (microsoft#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
deecewan authored and Max committed Oct 9, 2017
1 parent 751bf02 commit a585cbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CodePush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -503,6 +504,8 @@ function codePushify(options = {}) {
return <RootComponent {...props} />
}
}

return hoistStatics(extended, RootComponent);
}

if (typeof options === "function") {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a585cbb

Please sign in to comment.