3

I'm developing react-native app based on the latest 0.15.0 release via the NPM install/update method. Looking through the react-native MapView documentation it appears that it should support "image" prop in the "annotations" prop and "overlays" prop in the MapView. However, those props didn't work in my RN release.

After looking through the various branches in the react-native GitHub, I discovered that only the master branch has those props in MapView (See this). Since I'm keeping up with the RN releases via NPM. It is unclear to me how I can develop against the RN master branch.

Any idea?

One way that I can think of is to do a git pull of the master branch in my npm's node_modules and overwrite the react-native module. However, that seems drastic and I would also pull in many unneeded parts that requires deletion.

Another idea is to manually copy the master branch's MapView component and the corresponding iOS native files RCTMap… over but that seems inelegant and tedious.

Looking for a more elegant solution here.

T. Eric Hong
  • 550
  • 4
  • 12
  • Ask and thou shalt recieve: http://stackoverflow.com/questions/16350673/depend-on-a-branch-or-tag-using-a-git-url-in-a-package-json – Henrik Andersson Dec 01 '15 at 06:10

3 Answers3

5

You should be able to specify a git dependency in your package.json, like this:

"dependencies": {
  "react-native": "facebook/react-native",
},

npm will automatically clone the repo when installing. If you want to pin to a particular commit (highly recommended), do facebook/react-native#f025049b.

(Note that this strategy won't work for some packages like react itself which require a build step before npm, but react-native should work fine like this.)

Sophie Alpert
  • 126,406
  • 35
  • 212
  • 233
  • This won't work for native Android code which is released separately: http://bit.ly/1NnxrGl. It will work for JS and Obj-C code which is in npm / the github repo. The reason we don't build the Android code from source is that it's fairly expensive to do that and fast builds are very important for developer experience. – Martin Konicek Dec 01 '15 at 12:30
0

You could clone react native's repo locally and install it on your project:

> git clone https://github.com/facebook/react-native.git
> cd MyProject
> npm install ../react-native
0

For those in a similar position, but unwilling or unable for whatever reason to follow the master branch, you might consider waiting for the features.

From one of the primary contributors (paraphrased): React Native has a roughly 2 week cadence. A release candidate (rc) is derived from master at some point which begins the cycle. Two weeks later, it is promoted to release, and a new release candidate is created from the current state of master. The cycle then repeats. The MapView features you are hoping to use should show up in the next rc.

Chris
  • 311
  • 2
  • 13