-1

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;
Program-Me-Rev
  • 6,184
  • 18
  • 58
  • 142

1 Answers1

-3

Try importing path in this way

const path = '../imports/modules/core/startup/client';
import path;
sud007
  • 5,824
  • 4
  • 56
  • 63