import TestClass from './TestClass'
How do I reference TestClass
in this file given the string 'TestClass'
?
eval('TestClass')
doesn't work because TestClass is not defined
.
However, if I do let Test = TestClass
, and then eval('Test')
, it returns me the constructor for TestClass
, as desired.
Why does eval('TestClass')
not work when eval('Test')
does?
Context:
Given many elements like <div data-class="TestClass"></div>
, I want to create a generic function that renders the appropriate React components into them. These component classes will be imported into the file before executing this function.
Note: Using Brunch (similar to webpack) as the build system.