diff --git a/src/App.jsx b/src/App.jsx index 6bf3ac6..021d8b6 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,10 +1,39 @@ -// удаляем все, оставляя лишь пустую функцию App ниже +import React from 'react' + +class MyComponent extends React.Component { + constructor(props) { + super(props) + this.state = { count: 0 } + } + + componentDidMount() { + console.log('Компонент смонтирован') + } + + componentDidUpdate(prevProps,prevState) { + console.log('Компонент обнвлен') + if(prevState.count !== this.state.count) { + console.log('Состояние изменилось') + } + } + + componentWillUnmount() { + console.log('Компонент будет размонтирован') + } + + render() { + return
+ Привет мир! {this.props.name} {this.state.count} + +
+ } +} function App() { return ( <> - {/* Добавьте тестовый контент для проверки */}

Hello, React!

+ ) } diff --git a/src/main.jsx b/src/main.jsx index 950e96a..7e925e8 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -4,7 +4,5 @@ import { createRoot } from 'react-dom/client' import App from './App.jsx' createRoot(document.getElementById('root')).render( - - )