Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCAL-241097 Fix for liveboard shound not rerender if parent component… #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading