React hook - useRef - example timer
1. Import các thứ cần thiết
import {useState, useEffect, useRef} from 'react'
2. Tạo ref
const interValRef = useRef()
3. Tạo state timer
const [timer, setTimer] = useState(0)
4. Run timer
useEffect(() => {
setInterval(() => {
setTimer(timer => ...
kentrung.hashnode.dev1 min read