Comments (6)
Hey!
Great question – the configs are not bundled with js currently. They're defined in native land, where Gradle/Xcode can also read them.
It would be nice to have them defined in js too though, if anything because then we'd be able to reload the app to see config changes. CodePush support sounds great too, as long as developers understand that can't be used to change libraries setup natively (like the Facebook SDK, for instance).
I might take a stab at this at some point (aiming to use CodePush soon), but you're obviously welcome to give it a try too! Basically we'll have to generate a js file with the environment from .env
, and use that to override what's returned from the native layer.
Just not sure if we can get the packager to generate a js file for us based off .env
... would need to look into that.
from react-native-config.
Hey @pedro,
I think there is actually more value in keeping it all in native land. If we have config that we need defined in JS only, then there is nothing stopping you just using a JS file. From what you've said above it sounds like the env variables for a built app will be unchangeable, which could be helpful if for example you wanted to use the same JS app that behave differently depending upon an app configuration.
A good use case would be separate paid and free versions of the same app. You could have two builds that use the same JS file and simply detect from the .env whether all of the functionality should be available or not.
from react-native-config.
If we have config that we need defined in JS only, then there is nothing stopping you just using a JS file
Very true, but the idea here is exactly to have a single canonical way where all config is defined (.env
) and accessed from (import Config from 'react-native-config'
, in JS land at least). I'd hate to see people writing config.js
just so they can use it with CodePush, or to facilitate reloading under development. Thoughts?
from react-native-config.
Completely agree, if CodePush support could become a single source of truth (i.e. update native side and JS side). Not sure that that will be possible though? In which case, there would be two sources of truth, the JS bundle's truth and the native env's.
from react-native-config.
Right on! Yeah this could get confusing... Not sure how feasible it is either.
Well, I guess I'm closing this for now, but open to any further discussions/experimentations on this topic! Will update if I ever get to it too.
Thanks,
from react-native-config.
Hi,
I'm currently integrating with CodePush, and I was wondering if variables are still only kept in the native land?
from react-native-config.
Related Issues (20)
- Config is empty after upgrade to RN 0.71 HOT 32
- "/tmp/envfile" is buggy when its contents are empty string (iOS)
- Cannot invoke method toInteger() on null object HOT 2
- Inconsistent Environment File Loading in Android Studio vs React Native CLI
- ERROR in ./src/CONFIG.ts 3:0-41 [web-server] Module not found: Error: Can't resolve 'react-native-config' in '/Volumes/Personal/code-work/rn-projects/zaions/expensify-app-fork/src'
- is it possible to pass params but not set ENVFILE when run assemble release HOT 1
- How to import NSExceptionDomains as an environment variable?
- Variable are UNDEFINED on IOS HOT 14
- Could not find method android() for arguments [dotenv_4bgzrl46y7i0xnvnmgzr6qa4c$_run_closure1@3fa75e8b] on project ':app' of type org.gradle.api.Project.
- How to read config in Kotlin class in react native 0.73? HOT 1
- RNConfig Empty Android HOT 2
- MainApplication.kt:27:58 Type mismatch: inferred type is String but Boolean was expected HOT 1
- Not working on ReactNative 0.73 HOT 1
- Error retrieving namespace value from .env file during build process
- hey, did you find a way to make it work?
- Update the documentation HOT 3
- Issue with kotlin DSL
- ios undefined problem HOT 7
- [Question] - Is this lib abandoned?
- Compatibility of react-native-config with React Native 0.73+ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-config.