Giter Site home page Giter Site logo

Comments (6)

pedro avatar pedro commented on September 24, 2024 4

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.

deanmcpherson avatar deanmcpherson commented on September 24, 2024

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.

pedro avatar pedro commented on September 24, 2024

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.

deanmcpherson avatar deanmcpherson commented on September 24, 2024

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.

pedro avatar pedro commented on September 24, 2024

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.

Fouppy avatar Fouppy commented on September 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.