import React, { useState, Suspense } from 'react'; import Comp from 'remote/Image'; import { registerRemotes, loadRemote } from '@modern-js/runtime/mf'; const NewRemoteCom = React.lazy(() => loadRemote('remote/Image').then((m) => { console.log('加载'); return m; }), ); const Index = (): JSX.Element => { const [showComponent, setShowComponent] = useState(false); const replaceRemote = () => { console.log('replaceRemote click'); registerRemotes( [ { name: 'remote', entry: 'http://localhost:3055/mf-manifest.json', }, ], { force: true }, ); setShowComponent(true); }; return (

Static Remote

{/* replace remote */}
Desc Host component Remote component
This component is from a remote(localhost:3051)
click button to replace new remote Loading...}> {showComponent && }
); }; export default Index;