Require file with a variable in React JS
问题 I'm trying to require a file with a variable in the path. Something like const langCode = this.props.langCode; // en let languageFile = require('../common/languages/' + langCode); Where langCode can be fr, en, de, nl. Thus what I'm trying to get is for example require('../common/languages/en'); When I type it without variable at the end, thus require('../common/languages/en'); it works good. But when I try with require('../common/languages/' + langCode); it won't work, doesn't matter that the