Last active
April 13, 2018 07:39
-
-
Save beata/aa7e6e4c088416f73d6c956717133917 to your computer and use it in GitHub Desktop.
Require module defined in react-native-config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rn-cli.config.js | |
const fs = require('fs'); | |
const ini = require('ini'); | |
const path = require('path'); | |
let config = {}; | |
if (process.env.ENVFILE) { | |
config = ini.parse(fs.readFileSync(path.resolve(__dirname, process.env.ENVFILE), 'utf-8')); | |
} | |
module.exports = { | |
extraNodeModules: { | |
'APP_THEME': path.resolve(__dirname, 'src/themes/' + config.APP_THEME) | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# src/Root.js | |
import theme from 'APP_THEME'; // extraNodeModule defined in `rn-cli.config.js` | |
class Root extends Component { | |
store = getStore() | |
render() { | |
return ( | |
<Provider store={this.store}> | |
<ThemeProvider theme={theme}> | |
<App /> | |
</ThemeProvider> | |
</Provider> | |
); | |
} | |
} | |
export default Root; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment