2020-10-09 18:03:01 +07:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2020-10-09 18:08:22 +07:00
|
|
|
// import the countdown hook here
|
2020-10-09 18:03:01 +07:00
|
|
|
import { useCountdown } from 'cubetiq-react-use-countdown';
|
2020-09-07 16:42:09 +07:00
|
|
|
|
|
|
|
const App = () => {
|
2020-10-09 18:08:22 +07:00
|
|
|
const { timeleft, start } = useCountdown({
|
|
|
|
step: 1000,
|
|
|
|
});
|
|
|
|
|
2020-10-09 18:03:01 +07:00
|
|
|
return (
|
|
|
|
<div>
|
2020-10-09 18:08:22 +07:00
|
|
|
<button onClick={() => start(10000)}>Start Countdown</button>
|
2020-10-09 18:03:01 +07:00
|
|
|
<h1>Time left: {timeleft}</h1>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-09-07 16:42:09 +07:00
|
|
|
|
2020-10-09 18:03:01 +07:00
|
|
|
ReactDOM.render(<App />, document.querySelector('#root'));
|