Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mfrancois3k/eae12f315a3f6734008f4bf58cf54d4d to your computer and use it in GitHub Desktop.
Save mfrancois3k/eae12f315a3f6734008f4bf58cf54d4d to your computer and use it in GitHub Desktop.
React timer Modal
import _ as moment from 'moment';
export default function DailyReward(prosp) {
const [isShowModal, setIsShowModal] = useState<boolean>(false);
const [isRewardAvailible, setIsRewardAailible = useState<boolean>(false);
const [timeLeft, setTimeLeft] = useState(0) //in miliseconds
const [reward, setReward] = useState()
useEffect(() =>{
//fetch data
}, [])
const submitRewardHandler = () =>{
axios.post(...).then(res =>{
setReward(res.data)
}
const parsedTime = moment(timeLeft).format('HH:mm*)
return (
{timeleft && <div> {parsedTime} </div> }
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment