diff --git a/src/App.jsx b/src/App.jsx index 410e373..f6f5121 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,11 +2,13 @@ import styles from './App.module.scss' import Header from './components/header' import ProductList from './components/list' +import Timer from './components/timer' const App = () => { return (
+
) diff --git a/src/components/timer/index.jsx b/src/components/timer/index.jsx new file mode 100644 index 0000000..329f073 --- /dev/null +++ b/src/components/timer/index.jsx @@ -0,0 +1,21 @@ +import React, { useState, useEffect } from 'react' +import styles from './index.module.scss' + +const Timer = () => { + const [seconds, setSeconds] = useState(0); + useEffect(() => { + const interval = setInterval(() => { + setSeconds(prev => prev + 1); + }, 1000); + return () => { + clearInterval(interval); + }; + }, []); + return ( +
+

Прошло секунд: {seconds}

+
+ ); +} + +export default Timer \ No newline at end of file diff --git a/src/components/timer/index.module.scss b/src/components/timer/index.module.scss new file mode 100644 index 0000000..e69de29