JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g., /foo/g or /foo/y). They store a lastIndex from the previous match. Using this internally, test() can be used to iterate over multiple matches in a string of text (with capture groups).
const { gifs } = props
const [indexOfGif, setIndexOfGif] = useState(0)
const gifIntervalId = useRef(null)
const postRef = useRef(null)
useEffect(() => {
startGifInterval()
function changeGifClickHandler() {
if (gifIntervalId.current) {
clearInterval(gifIntervalId.current)
}
}
postRef.current.addEventListener('click', changeGifClickHandler)
return () => {
postRef.current.removeEventListener('click', changeGifClickHandler)
clearInterval(gifIntervalId.current)
}
}, [gifs])
function startGifInterval() {
if (!gifIntervalId.current) {
gifIntervalId.current = setInterval(() => {
setIndexOfGif((prevInd) => (prevInd + 1) % gifs.length)
}, 1000)
}
}
const [words, setWords] = useState([])
useEffect(() => {
localStorage.setItem('words', JSON.stringify(words))
}, [words])
token.exp
с текущим временем, если устарел или устареет в течение запроса, то сначала запросить новый и сделать запрос.const StyledLink = styled.a`
color: #f00;
`
<Link href={} passHref><StyledLink>My Link</StyledLink></Link>
curl 'http://dhl.com/' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7' \
--compressed \
--insecure -I
TP/1.0 301 Moved Permanently
Location: http://www.dhl.com/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0