File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-dynamic-remote-component" ,
3
- "version" : " 0.0.3 " ,
3
+ "version" : " 0.0.4 " ,
4
4
"description" : " Allows you to dynamically load a component from a remote using webpack 5's module federation." ,
5
5
"keywords" : [
6
6
" react" ,
Original file line number Diff line number Diff line change 1
- import { FC } from "react" ;
2
1
import { attachScript } from "./attach-script" ;
3
2
import { loadModule } from "./load-module" ;
4
- import { RemoteModule } from "./types" ;
5
3
import { suspend } from "./suspend" ;
4
+ import { RemoteModule } from "./types" ;
6
5
import { getRemoteModuleId } from "./utils" ;
7
6
8
7
export type RemoteComponentProps = RemoteModule & {
@@ -52,12 +51,21 @@ export const useRemoteModule = (remoteModule: RemoteModule) => {
52
51
return getModuleSuspended ( remoteModule ) ;
53
52
} ;
54
53
55
- export const RemoteComponent : FC < RemoteComponentProps > = ( {
56
- unLoadScriptOnUnmount = true ,
57
- exportName = "default" ,
58
- ...remoteModule
59
- } ) => {
60
- const { [ exportName ] : Component } = getModuleSuspended ( remoteModule ) ;
54
+ export function RemoteComponent < ExtraProps > ( props : RemoteComponentProps ) {
55
+ const {
56
+ unLoadScriptOnUnmount = true ,
57
+ exportName = "default" ,
58
+ url,
59
+ scope,
60
+ module,
61
+ ...componentProps
62
+ } = props ;
61
63
62
- return < Component /> ;
63
- } ;
64
+ const { [ exportName ] : Component } = getModuleSuspended ( {
65
+ url,
66
+ scope,
67
+ module,
68
+ } ) ;
69
+
70
+ return < Component { ...componentProps } /> ;
71
+ }
You can’t perform that action at this time.
0 commit comments