Want to load local text file into string variable in ReactNative Project? Create a constants.js like below, where you are exporting the constants.
1 2 3 4 5 6 7 8 | module.exports = { SPRING_CONFIG: {tension: 40, friction: 3}, COLOR: { COLOR1: '#ffffff', COLOR2: '#eeeeee', BLACK_TEXT: '#333', }, }; |
Then in whatever file you are trying to import it, import it as.
1 2 3 4 | //Make sure you put the right folder path. import CONSTANTS from './constants'; console.log(CONSTANTS.COLOR.BLACK_TEXT); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.