mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: memorize callback to reduce event registrations
This commit is contained in:
parent
58a63bc77b
commit
712c56cbb8
1 changed files with 4 additions and 8 deletions
|
|
@ -49,17 +49,13 @@ export function Resizable({ baseSize, className, children }: React.PropsWithChil
|
|||
size,
|
||||
)
|
||||
|
||||
const onResize = React.useCallback((size: number) => {
|
||||
if (size < window.innerWidth - MINIMAL_CONTENT_VIEWPORT_WIDTH) setSize(size)
|
||||
}, [])
|
||||
return (
|
||||
<div className={cx('gitako-position-wrapper', className)}>
|
||||
<div className={'gitako-position-content'}>{children}</div>
|
||||
{features.resize && (
|
||||
<HorizontalResizeHandler
|
||||
onResize={size => {
|
||||
if (size < window.innerWidth - MINIMAL_CONTENT_VIEWPORT_WIDTH) setSize(size)
|
||||
}}
|
||||
size={size}
|
||||
/>
|
||||
)}
|
||||
{features.resize && <HorizontalResizeHandler onResize={onResize} size={size} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue