diff --git a/src/react/index.tsx b/src/react/index.tsx index 1acc0042..264a34d2 100644 --- a/src/react/index.tsx +++ b/src/react/index.tsx @@ -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'; @@ -19,13 +19,12 @@ const componentFactory = React.forwardRef, U>( +) => memo(React.forwardRef, U>( + (props: U, forwardedRef: React.MutableRefObject>) => { const ref = React.useRef(null); const { className, ...embedProps } = props; - const { viewConfig, listeners } = getViewPropsAndListeners, V>( - embedProps, - ); + const { viewConfig, listeners } = getViewPropsAndListeners, V>(embedProps); const handleDestroy = (tsEmbed: InstanceType) => { // do not destroy if it is a preRender component @@ -94,7 +93,7 @@ const componentFactory = ); }, -); +)); interface SearchProps extends EmbedProps, SearchViewConfig { }