/
dedaMazai
/
reactGoodPattern
Обзор
Документация
Войти
/
dedaMazai
/
reactGoodPattern
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/entities/Counter/ui/Counter.tsx
42 строки
992 B
Andrei Chipizubov
fix
24 май 2023, 10:41
24 май 2023, 10:41
8be4b6e
Код
Авторство
О чём код?
import { useTranslation } from 'react-i18next'; import { useCounterValue } from '../model/selectors/getCounter'; import { useCounterActions } from '../model/slice/counterSlice'; export const Counter = () => { const counterValue = useCounterValue(); const { t } = useTranslation(); const { decrement, increment, add } = useCounterActions(); const handleInc = () => { increment(); }; const handleDec = () => { decrement(); }; const handleAddFive = () => { add(5); }; return ( <div> <h1>{counterValue}</h1> <button onClick={handleAddFive} > {t('add5')} </button> <button onClick={handleInc} > {t('increment')} </button> <button onClick={handleDec} > {t('decrement')} </button> </div> ); };