Skip to content

Commit

Permalink
fix: prevent destroy/render remote component every time rerendering f…
Browse files Browse the repository at this point in the history
…rom host
  • Loading branch information
ducdv-lumin committed Feb 4, 2025
1 parent f141396 commit a2e87fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/bridge/bridge-react/src/create.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef } from 'react';
import React, { forwardRef, useMemo } from 'react';
import {
ErrorBoundary,
ErrorBoundaryPropsWithComponent,
Expand Down Expand Up @@ -102,7 +102,7 @@ export function createRemoteComponent<T, E extends keyof T>(

return forwardRef<HTMLDivElement, ProviderParams & RawComponentType>(
(props, ref) => {
const LazyComponent = createLazyRemoteComponent(info);
const LazyComponent = useMemo(() => createLazyRemoteComponent(info), []);
return (
<ErrorBoundary FallbackComponent={info.fallback}>
<React.Suspense fallback={info.loading}>
Expand Down

0 comments on commit a2e87fe

Please sign in to comment.