@@ -130,49 +130,3 @@ export function NavLink(props: PropsWithChildren<NavLinkProps>) {
130
130
131
131
return React . createElement ( Link , { ...rest , to } )
132
132
}
133
-
134
- interface ImportProps {
135
- from : string
136
- name ?: string // default is 'default'
137
- props ?: Record < string , any >
138
- fallback ?: ReactElement
139
- }
140
-
141
- export function Import ( props : ImportProps ) {
142
- const { __importer, __sourceFile } = ( props as any )
143
- const [ error , setError ] = useState < string | null > ( null )
144
- const [ mod , setMod ] = useState < { Component : ComponentType | null } > ( { Component : null } )
145
-
146
- useEffect ( ( ) => {
147
- if ( reModuleExt . test ( __sourceFile ) ) {
148
- const p = util . splitPath ( __importer )
149
- p . pop ( )
150
- import ( util . cleanPath ( '/_aleph/' + p . join ( '/' ) + '/' + props . from ) )
151
- . then ( mod => {
152
- const Component = mod [ props . name || 'default' ]
153
- if ( util . isLikelyReactComponent ( Component ) ) {
154
- setMod ( { Component } )
155
- } else {
156
- setError ( `component${ props . name ? ` '${ props . name } '` : '' } not found` )
157
- }
158
- } )
159
- . catch ( ( err : Error ) => {
160
- setError ( err . message )
161
- } )
162
- }
163
- } , [ __importer , __sourceFile ] )
164
-
165
- if ( error ) {
166
- return React . createElement ( 'div' , { style : { color : 'red' } } , error )
167
- }
168
-
169
- if ( mod . Component ) {
170
- return React . createElement ( mod . Component , props . props )
171
- }
172
-
173
- if ( reModuleExt . test ( __sourceFile ) && props . fallback ) {
174
- return props . fallback
175
- }
176
-
177
- return null
178
- }
0 commit comments