Skip to content

Commit 2f99d01

Browse files
SCAL-241097 Fix for liveboard shound not rerender if parent component rerenders
1 parent facf4a5 commit 2f99d01

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/react/index.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { memo } from 'react';
22
import useDeepCompareEffect from 'use-deep-compare-effect';
33
import { deepMerge } from '../utils';
44
import { SearchBarEmbed as _SearchBarEmbed, SearchBarViewConfig } from '../embed/search-bar';
@@ -19,13 +19,12 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
1919
// Embed.preRender() method instead of the usual render method, and it will
2020
// not be destroyed when the component is unmounted.
2121
isPreRenderedComponent = false,
22-
) => React.forwardRef<InstanceType<T>, U>(
22+
) => memo(React.forwardRef<InstanceType<T>, U>(
23+
2324
(props: U, forwardedRef: React.MutableRefObject<InstanceType<T>>) => {
2425
const ref = React.useRef<HTMLDivElement>(null);
2526
const { className, ...embedProps } = props;
26-
const { viewConfig, listeners } = getViewPropsAndListeners<Omit<U, 'className'>, V>(
27-
embedProps,
28-
);
27+
const { viewConfig, listeners } = getViewPropsAndListeners<Omit<U, 'className'>, V>(embedProps);
2928

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

9998
interface SearchProps extends EmbedProps, SearchViewConfig { }
10099

0 commit comments

Comments
 (0)