Skip to content

Commit 033b96a

Browse files
Copilothotlong
andcommitted
refactor: convert LazyPluginLoader to JSX syntax per code review feedback
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent f28f350 commit 033b96a

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

packages/react/src/LazyPluginLoader.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ class PluginErrorBoundary extends Component<
5353
if (this.state.hasError && this.state.error) {
5454
const FallbackComponent = this.props.fallback;
5555
if (FallbackComponent) {
56-
return React.createElement(FallbackComponent, {
57-
error: this.state.error,
58-
retry: this.handleRetry,
59-
});
56+
return <FallbackComponent error={this.state.error} retry={this.handleRetry} />;
6057
}
6158
return null;
6259
}
@@ -136,17 +133,17 @@ export function createLazyPlugin<P extends object = any>(
136133
const LazyComponent = lazy(retryImport);
137134

138135
const PluginWrapper: React.FC<P> = (props) => {
139-
const content = React.createElement(
140-
Suspense,
141-
{ fallback: options?.fallback || null },
142-
React.createElement(LazyComponent, props),
136+
const content = (
137+
<Suspense fallback={options?.fallback || null}>
138+
<LazyComponent {...props} />
139+
</Suspense>
143140
);
144141

145142
if (errorFallback) {
146-
return React.createElement(
147-
PluginErrorBoundary,
148-
{ fallback: errorFallback },
149-
content,
143+
return (
144+
<PluginErrorBoundary fallback={errorFallback}>
145+
{content}
146+
</PluginErrorBoundary>
150147
);
151148
}
152149

0 commit comments

Comments
 (0)