Below is the code
require("index/components/" + name); //fails
require("index/components/myComponent"); //work fine
any good solution ?
Dynamic paths in require are not currently supported. Please check this answer
This is covered in the documentation under the section "Static Resources":
The only allowed way to refer to an image in the bundle is to literally write require('name-of-the-asset') in the source.
You can use a switch statement to implement this.
../../../assets/Static_Icons/${name}.${fileType};` ` iconSrc = require(path);`