Created
March 1, 2020 21:13
-
-
Save DZuz14/e2362236883d765fd5433939af952768 to your computer and use it in GitHub Desktop.
useRef and useEffect in tandem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect, useRef } from 'react' | |
const autoPlayRef = useRef() | |
useEffect(() => { | |
autoPlayRef.current = nextSlide | |
}) | |
...rest of Slider component |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment