/
bearury
/
ui-kit-ce
Обзор
Документация
Войти
/
bearury
/
ui-kit-ce
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/hooks/examples/OutsideClickExample.tsx
51 строка
1 KB
Denis Svyatovets
refactor: правки для работы с next 15
10 июн 2025, 12:52
10 июн 2025, 12:52
1b1b5f4
Код
Авторство
О чём код?
import * as React from 'react' import { useOutsideClick, useTheme } from '@v-uik/base' type OutsideClickExampleProps = { onSubmit?: (value: number) => void } export const OutsideClickExample: React.FC<OutsideClickExampleProps> = ({ onSubmit, }) => { const state = React.useState(0) const theme = useTheme() const ref = useOutsideClick(() => { const setState = state[1] setState((x) => { const newValue = x + 1 onSubmit?.(newValue) return newValue }) }) return ( <div style={{ display: 'flex', flexDirection: 'column', gap: 8, width: 708 }} > <div style={{ width: 150, height: 150, background: theme.ref.palette.red90, display: 'flex', justifyContent: 'center', alignSelf: 'center', alignItems: 'center', }} > <div ref={ref} style={{ width: 50, height: 50, background: theme.ref.palette.herbal60, }} /> </div> </div> ) }