Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New React Native project with old version of react native

I am trying to create a new react native project which should utilize an older version of react-native.

The result I would like would be to do something like: react-native init MyProject but have the version of react-native it uses be 0.13.2.

However, there doesn't seem to be any options with react-native-cli for initializing with old versions of react-native.

Performing react-native init MyProject and then dowgrading react-native in package.json also does not work because the init command installs a bunch of xcode templates which are used to build the app and there is no dowgrade command which will dowgrade these templates. (There is an upgrade command.)

I tried downgrading my version of react-native-cli to 0.1.4 which was current when react-native 0.13 was current, but this did not work. From looking at the cli source, it seems it always initializes with just the newest version of react-native.

I realize this is pretty weird to want to start a new project at an old version, but I have a weird set of requirements that are forcing this.

like image 734
Jordan Ell Avatar asked Dec 10 '15 20:12

Jordan Ell


People also ask

How do I downgrade react version to an existing project?

Search for the react and react-dom packages under dependencies (or devDependencies ) and replace their versions with 16.13. 0 . Then run npm install or yarn or whatever package manager you're using. This should be enough to downgrade to React 16.

How do I upgrade React Native to an existing project?

Because typical React Native projects are essentially made up of an Android project, an iOS project, and a JavaScript project, upgrading can be rather tricky. There's currently two ways for upgrading your React Native project: by using React Native CLI or manually with Upgrade Helper.


2 Answers

There is a new parameter in react-native init that allows just this. Try:

react-native init --version="[email protected]" MyNewApp 

Here my source. I have successfully tested it with react-native-cli 2.0.1.

like image 145
martinarroyo Avatar answered Sep 23 '22 21:09

martinarroyo


rninit is a replacement for react-native init that allows you to specify a particular version of react-native to use.

Install rninit globally:

npm install -g rninit 

Specify which version of react-native to use:

rninit init [Project Name] --source [email protected] 

Thanks to @vanson-wing-leung for pointing me to rninit

like image 26
emmby Avatar answered Sep 19 '22 21:09

emmby