Skip to content

feat: добавлен lesson-31#19

Merged
vvscode merged 5 commits into
masterfrom
lesson31
Oct 14, 2025
Merged

feat: добавлен lesson-31#19
vvscode merged 5 commits into
masterfrom
lesson31

Conversation

@vvscode

@vvscode vvscode commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator

No description provided.


Жизненные этапы и циклы React-компонента

<img src="./images/react-lifecycle.jpg" title="react lifecicles" />

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

без знания о классовых компонентах эта картинка вроде не много говорит

Uploading image.png…

может такое? (или просто добавить)

Comment thread lessons/lesson31/lesson.md Outdated

<!-- v -->

[useState](https://react.dev/reference/react/useState) - это хук React, который позволяет добавить переменную состояния в компонент.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в старой документации есть описание на русском https://ru.legacy.reactjs.org/docs/hooks-effect.html

Comment thread lessons/lesson31/lesson.md Outdated

<!-- v -->

[useState](https://react.dev/reference/react/useState) - это хук React, который позволяет добавить переменную состояния в компонент.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в старой документации есть описание на русском https://ru.legacy.reactjs.org/docs/hooks-effect.html


- **Текущее состояние** (state). Во время первого рендера оно будет соответствовать переданному вами **initialState**.

- **Функция set** (setState), которая позволяет обновить состояние до другого значения и вызвать повторный рендеринг.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

прошу обратить внимание что нейминг произвольный, и что есть соглашение об именовании

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нейминг взят отсюда
https://react.dev/reference/react/useState


return (
<>
<input value={text} onChange={handleChange} />

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут полезно проговорить про разницу реактовского onChange и нативного события change

return (
<>
<input value={name} onChange={(e) => setName(e.target.value)} />
<button onClick={() => setAge(age + 1)}>Increment age</button>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я дальше не смотрел, но на всякий случай - проговорить тут студентам, что так писать не нужно, а нужна сигнатура с мутацией.setAge(age => age + 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, это проговорю

const [user, setUser] = useState(null);
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проговорить почему тут нельзя async использовать https://devtrium.com/posts/async-functions-useeffect

@AlaYafremava AlaYafremava changed the title feat: добавлен lesson-31 WIP feat: добавлен lesson-31 Oct 14, 2025
@vvscode vvscode merged commit 7dac46d into master Oct 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants