Compare commits

..

1 Commits

5 changed files with 86 additions and 1292 deletions
+68 -1247
View File
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -10,9 +10,10 @@
"preview": "vite preview"
},
"dependencies": {
"info": "^1.0.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
"react-dom": "^19.1.0",
"react-error-boundary": "^6.1.2",
"react-router-dom": "^7.17.0"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
@@ -23,8 +24,6 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"sass": "^1.99.0",
"sass-embedded": "^1.99.0",
"vite": "^6.3.5"
}
}
+14 -18
View File
@@ -1,29 +1,25 @@
import styles from './styles/App.module.scss'
import React, { useState, useCallback } from 'react'
import { Suspense, lazy } from 'react'
import { ErrorBoundary } from 'react-error-boundary'
function CounterButton({label, onClick}) {
const LazyComponent = lazy(() => import('./MyComponent'))
function ErrorFallBack({error, resetErrorBoundary }) {
return (
<button onClick={onClick} className={styles.counter_button}>{label}</button>
<div>
<h2>Что то сломалось</h2>
<button onClick={resetErrorBoundary}></button>
</div>
)
}
function CounterDisplay({value}) {
return (<div className={styles.counter_display}>
Значение счетчика: <b>{value}</b>
</div>)
}
function App() {
const [counter,setCounter] = useState(0);
const increment = () => setCounter(prev => prev + 1);
const decrement = () => setCounter(prev => prev - 1);
return (
<>
<h2>Практика по созданию счетчика с колбэками</h2>
<CounterButton label="Увеличить" onClick={increment} />
<CounterButton label="уменьшить" onClick={decrement} />
<CounterDisplay value={counter} />
<ErrorBoundary FallBackComponent={ErrorFallBack}>
<Suspense fallback={<div>Загрузка ...</div>}>
<LazyComponent />
</Suspense>
</ErrorBoundary>
</>
)
}
+1 -1
View File
@@ -1,6 +1,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
// удаляем import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
-22
View File
@@ -1,22 +0,0 @@
.container {
display:flex;
flex-direction: row;
border: 1px solid black;
border-radius: 5px;
margin-bottom: 10px;
p {
padding: 5px 10px;
}
}
.counter {
&_display{
border: 1px solid black;
border-width: 3px;
border-radius: 10px;
padding: 10px;
width: 300px;
}
&_button{
padding: 10px;
}
}