разобрались с чистыми компонетами

This commit is contained in:
2026-05-14 20:25:06 +03:00
parent 169ce23bed
commit 7bb32d1a0b
3 changed files with 23 additions and 0 deletions
+2
View File
@@ -2,11 +2,13 @@ import styles from './App.module.scss'
import Header from './components/header' import Header from './components/header'
import ProductList from './components/list' import ProductList from './components/list'
import Timer from './components/timer'
const App = () => { const App = () => {
return ( return (
<div className={styles.container}> <div className={styles.container}>
<Header /> <Header />
<Timer />
<ProductList /> <ProductList />
</div> </div>
) )
+21
View File
@@ -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 (
<div>
<h2>Прошло секунд: {seconds}</h2>
</div>
);
}
export default Timer