react-native icon indicating copy to clipboard operation
react-native copied to clipboard

How to get the version of react-native in native code?

Open cxfeng1-zz opened this issue 11 years ago • 3 comments

For some reason I need to request different URLs with different react-native versions, is there a convenient way to get the version in my Objective-C code?

cxfeng1-zz avatar Jul 13 '15 12:07 cxfeng1-zz

You could use package.json from {project}/node_modules/react-native/package.json. It should always be available and it does have the version of the used react-native.

But I don't think that you should depend on a version number of react-native in Objective-C. I personally would prefer to check for the existence of code I wanted to use, but of course it can be different I your use case.

DannyvanderJagt avatar Jul 13 '15 20:07 DannyvanderJagt

@DannyvanderJagt the package.json will not be available when my app is published.

I use the version to make sure my native code and remote JS code are of same version.

See this: #1732

cxfeng1-zz avatar Jul 14 '15 04:07 cxfeng1-zz

@cxfeng1 - that should just be pulled into the bundle if you require it

brentvatne avatar Jul 20 '15 19:07 brentvatne