Skip to content

Commit

Permalink
Honor the version of "react" under peerDeps when setting up a new pro…
Browse files Browse the repository at this point in the history
…ject

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 facebook#6846

Differential Revision: D3148182

Pulled By: sebmarkbage

fb-gh-sync-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
fbshipit-source-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
  • Loading branch information
ide authored and Facebook Github Bot 9 committed Apr 7, 2016
1 parent eecdf7d commit c30d125
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion local-cli/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ module.exports = yeoman.generators.NamedBase.extend({
return;
}

this.npmInstall('react', { '--save': true });
var reactNativePackageJson = require('../../package.json');
var { peerDependencies } = reactNativePackageJson;
if (!peerDependencies) {
return;
}

var reactVersion = peerDependencies.react;
if (!reactVersion) {
return;
}

this.npmInstall(`react@${reactVersion}`, { '--save': true });
}
});

0 comments on commit c30d125

Please sign in to comment.