Skip to content

Commit 303a264

Browse files
committed
Honor the version of "react" under peerDeps when setting up a new project
Summary:We need this since React 15.0.0 is coming and will break `react-native init`, which currently installs the latest version of React. We'll need some changes to React Native to support 15 that Sebastian is actively working on, but till that lands we want `react-native init` to continue working. Closes #6846 Differential Revision: D3148182 Pulled By: sebmarkbage fb-gh-sync-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b fbshipit-source-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
1 parent db8273e commit 303a264

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

local-cli/generator/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ module.exports = yeoman.generators.NamedBase.extend({
9292
return;
9393
}
9494

95-
this.npmInstall('react', { '--save': true });
95+
var reactNativePackageJson = require('../../package.json');
96+
var { peerDependencies } = reactNativePackageJson;
97+
if (!peerDependencies) {
98+
return;
99+
}
100+
101+
var reactVersion = peerDependencies.react;
102+
if (!reactVersion) {
103+
return;
104+
}
105+
106+
this.npmInstall(`react@${reactVersion}`, { '--save': true });
96107
}
97108
});

0 commit comments

Comments
 (0)