Skip to content

Instantly share code, notes, and snippets.

@multivoltage
Created September 25, 2022 09:14
Show Gist options
  • Save multivoltage/c223278303737e5a317eda9710d355c2 to your computer and use it in GitHub Desktop.
Save multivoltage/c223278303737e5a317eda9710d355c2 to your computer and use it in GitHub Desktop.
strange solution
// App.tsx
function App(){
return <>
{false && <MyComp />}
</>
}
// MyComp.tsx
// myModule.js is a normal npm package
function MyComp(){
const [mounted,setMounted] = useState(false)
const ref = useRef<any>()
useEffect(() => {
import("myModule.js").then(myModule){
const { Pippo, Pluto } = myModule
Pippo.init(Pluto)
ref.current = Pluto
setMounted(true)
}
},[])
if(!mounted)
return <span/>
return <ref.current optitions={...}/>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment