Skip to content

Commit

Permalink
SCAL-241097 Fix for liveboard shound not rerender if parent component…
Browse files Browse the repository at this point in the history
… rerenders
  • Loading branch information
adityamittal3107 committed Feb 4, 2025
1 parent facf4a5 commit 2f99d01
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/react/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { memo } from 'react';
import useDeepCompareEffect from 'use-deep-compare-effect';
import { deepMerge } from '../utils';
import { SearchBarEmbed as _SearchBarEmbed, SearchBarViewConfig } from '../embed/search-bar';
Expand All @@ -19,13 +19,12 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
// Embed.preRender() method instead of the usual render method, and it will
// not be destroyed when the component is unmounted.
isPreRenderedComponent = false,
) => React.forwardRef<InstanceType<T>, U>(
) => memo(React.forwardRef<InstanceType<T>, U>(

(props: U, forwardedRef: React.MutableRefObject<InstanceType<T>>) => {
const ref = React.useRef<HTMLDivElement>(null);
const { className, ...embedProps } = props;
const { viewConfig, listeners } = getViewPropsAndListeners<Omit<U, 'className'>, V>(
embedProps,
);
const { viewConfig, listeners } = getViewPropsAndListeners<Omit<U, 'className'>, V>(embedProps);

const handleDestroy = (tsEmbed: InstanceType<T>) => {
// do not destroy if it is a preRender component
Expand Down Expand Up @@ -94,7 +93,7 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
<div data-testid="tsEmbed" ref={ref} className={className}></div>
);
},
);
));

interface SearchProps extends EmbedProps, SearchViewConfig { }

Expand Down

0 comments on commit 2f99d01

Please sign in to comment.