@@ -13,7 +13,6 @@ export type State = {
13
13
14
14
export type Props = {
15
15
src : string ,
16
- type ?: ?string ,
17
16
onLoad ?: ?( ) => any ,
18
17
onError ?: ?( error : Error ) => any ,
19
18
children ?: ?( state : State ) => ?React . Node ,
@@ -74,12 +73,19 @@ export default class ScriptLoader extends React.PureComponent<Props, State> {
74
73
}
75
74
76
75
render ( ) : React . Node {
77
- const { children, type, src } = this . props
76
+ const {
77
+ children,
78
+ /* eslint-disable no-unused-vars */
79
+ onLoad,
80
+ onError,
81
+ /* eslint-enable no-unsued-vars */
82
+ ...props
83
+ } = this . props
78
84
return (
79
85
< ScriptsRegistryContext . Consumer >
80
86
{ ( context : ?ScriptsRegistry ) => {
81
87
if ( context ) {
82
- context . scripts . push ( { type , src } )
88
+ context . scripts . push ( props )
83
89
if ( ! children ) return < React . Fragment />
84
90
const result = children ( {
85
91
loading : true ,
@@ -102,15 +108,14 @@ export default class ScriptLoader extends React.PureComponent<Props, State> {
102
108
103
109
export class ScriptsRegistry {
104
110
scripts : Array < {
105
- type ?: ?string ,
106
111
src : string ,
107
112
} > = [ ]
108
113
109
114
scriptTags ( ) : React . Node {
110
115
return (
111
116
< React . Fragment >
112
- { this . scripts . map ( ( { type , src } , index ) => (
113
- < script key = { index } type = { type } src = { src } />
117
+ { this . scripts . map ( ( props , index ) => (
118
+ < script key = { index } { ... props } />
114
119
) ) }
115
120
</ React . Fragment >
116
121
)
0 commit comments