I'm trying to import
the mule uploader package in es6
, but the source file uses an IIFE that expects the window
scope to be passed as a parameter.
What is the correct es6
syntax for importing the package and passing in the correct parameters to the IIFE
?
Note: the problem with import { mule_upload } from 'mule-uploader
isn't that the code isn't there or being executed. The problem is the correct scope
or namespace
is not being passed in with the IIFE
runs.
App.jsx
import { mule_upload } from 'mule-uploader'
// this runs the mule-uploader file with the IIFE
// since `this` is not `window` at this point,
// the mule-uploader object has the incorrect scope/namespace
console.log(this) // undefined
// ... react logic
componentDidMount() {
// define settings
// this won't work because the namespace is undefined
mule_upload(settings)
}