PowerShell Module Params accessible before componentDidMount()

I need to have information from the PowerShell Module to determine what Imports to make in my component.jsx.
It appears that I can only access this.props.myModuleParams after componentDidMount(). But at that time I can’t import additional modules.

Normally you’d just import them all, but I’m actually making imports that contain configuration for other modules so I can’t change the Property as it is used by downstream modules.
Likewise if it was the full module I needed then I could use require(’./script’).

I’m a bit stumped. I want the Financial Chart - Beta module to have multiple chart type options. Without some major work refactoring react-stockcharts I’m thinking it isn’t possible.

Any ideas/guidance would be greatly appreciated.


You can you dynamic import, import(’./module-to-import’).then(({default-export}) => console.log(default-export))

This is how i load the icons in ud

I don’t have enough info to do the Import until I’m in componentDidMount().
Then I can’t do the Import anymore as I’m inside the Class.

How can I either have the this.props vars earlier or import from within the Class ?


If you console.log this.props when you in component will mount what do you get?

import(`@ …
some babel syntax/function ?
Thx for the info, I’ll give it a crack tomorrow.


Its called dynamic import, take a look at the like i send you above from the react.js site

fantastic thx @AlonGvili I really appreciate the help.
That pointed me in the right direction.
I was able to solve with

myThing = React.lazy(() => import('./myScript'));