Reputation: 2949
I have a file config.js
which contain various objects and arrays. It is a large file so i decided to keep it as a separate file. I want to read this array called Config.EmojiCategorySpritesheetDimens
from my config.js
file in a component file called TextDisplay.js
. How could this be done using React or React-Redux. Please help
config.js
var Config = {};
Config.Emoji = {
"00a9": ["\u00A9", ["copyright"]],
"00ae": ["\u00AE", ["registered"]],
"203c": ["\u203C", ["bangbang"]],
"2049": ["\u2049", ["interrobang"]],
"2122": ["\u2122", ["tm"]],
...etc
}
Config.EmojiCategorySpritesheetDimens = [
[7, 27],
[4, 29],
[7, 33],
[3, 34],
[7, 34]
];
Upvotes: 4
Views: 8305
Reputation: 11693
Using module.export, I succeed reading the table:
var Config = {};
Config.Emoji = {
"00a9": ["\u00A9", ["copyright"]],
"00ae": ["\u00AE", ["registered"]],
"203c": ["\u203C", ["bangbang"]],
"2049": ["\u2049", ["interrobang"]],
"2122": ["\u2122", ["tm"]]
}
Config.EmojiCategorySpritesheetDimens = [
[7, 27],
[4, 29],
[7, 33],
[3, 34],
[7, 34]
];
module.exports = Config;
config.js is then available in all the component defined in TextDisplay.js
Upvotes: 3