I am trying to set require()
with a dynamic path myPath
:
let myPath = './myDynamicModule';
require( { myPath } )
but I keep getting the error :
error: bundling failed: myComponent.js: myComponent.js:Invalid call at line 9: require({
myPath: myPath
})
What am I doing wrong?
Thank you all in advance.
UPDATE
import React, { Component } from 'react';
const ComponentIndex = ({ myModule }) => {
const myPath = '../modules/' + myModule;
RevRetComponent = require(revPath).default;
return <RevRetComponent />;
}
export default ComponentIndex;