1
- import React from 'react' ;
1
+ import React , { memo } from 'react' ;
2
2
import useDeepCompareEffect from 'use-deep-compare-effect' ;
3
3
import { deepMerge } from '../utils' ;
4
4
import { SearchBarEmbed as _SearchBarEmbed , SearchBarViewConfig } from '../embed/search-bar' ;
@@ -19,13 +19,12 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
19
19
// Embed.preRender() method instead of the usual render method, and it will
20
20
// not be destroyed when the component is unmounted.
21
21
isPreRenderedComponent = false ,
22
- ) => React . forwardRef < InstanceType < T > , U > (
22
+ ) => memo ( React . forwardRef < InstanceType < T > , U > (
23
+
23
24
( props : U , forwardedRef : React . MutableRefObject < InstanceType < T > > ) => {
24
25
const ref = React . useRef < HTMLDivElement > ( null ) ;
25
26
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 ) ;
29
28
30
29
const handleDestroy = ( tsEmbed : InstanceType < T > ) => {
31
30
// do not destroy if it is a preRender component
@@ -94,7 +93,7 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
94
93
< div data-testid = "tsEmbed" ref = { ref } className = { className } > </ div >
95
94
) ;
96
95
} ,
97
- ) ;
96
+ ) ) ;
98
97
99
98
interface SearchProps extends EmbedProps , SearchViewConfig { }
100
99
0 commit comments