/
Percival
/
reactJS_course
Обзор
Документация
Войти
/
Percival
/
reactJS_course
Код
Запросы
4
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
task6
task_1_fsd/src/features/refExamples/PreviousInput.tsx
24 строки
611 B
Rituparn
Added the 5th task
26 окт 2025, 19:34
26 окт 2025, 19:34
72790f9
Код
Авторство
О чём код?
import { useState, useRef, useEffect } from 'react'; export const PreviousInput = () => { const [currentValue, setCurrentValue] = useState(''); const previousValueRef = useRef(''); useEffect(() => { previousValueRef.current = currentValue; }, [currentValue]); return ( <div> <h3>PreviousInput</h3> <input type="text" value={currentValue} onChange={(e) => setCurrentValue(e.target.value)} placeholder="Type something..." /> <p>Current value: {currentValue}</p> <p>Previous value: {previousValueRef.current}</p> </div> ); };