Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions content/tutorial/01-svelte/07-lifecycle/02-update/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: beforeUpdate and afterUpdate
title: beforeUpdate와 afterUpdate
---

The `beforeUpdate` function schedules work to happen immediately before the DOM is updated. `afterUpdate` is its counterpart, used for running code once the DOM is in sync with your data.
`beforeUpdate` 함수는 DOM이 업데이트되기 직전에 작업을 예약합니다. `afterUpdate`는 그 반대 역할을 하며, DOM이 데이터와 동기화된 후에 코드를 실행하는 데 사용됩니다.

Together, they're useful for doing things imperatively that are difficult to achieve in a purely state-driven way, like updating the scroll position of an element.
이 둘을 함께 사용하면 요소의 스크롤 위치를 업데이트하는 것과 같이 순수한 상태 기반 방법으로는 달성하기 어려운 작업을 명령적으로 수행할 수 있어 유용합니다.

This [Eliza](https://en.wikipedia.org/wiki/ELIZA) chatbot is annoying to use, because you have to keep scrolling the chat window. Let's fix that.
[Eliza](https://en.wikipedia.org/wiki/ELIZA) 챗봇은 채팅 창을 계속 스크롤해야 해서 사용하기 불편합니다. 이를 해결해 봅시다.

```js
/// file: App.svelte
Expand All @@ -27,4 +27,4 @@ afterUpdate(() => {
});
```

Note that `beforeUpdate` will first run before the component has mounted, so we need to check for the existence of `div` before reading its properties.
`beforeUpdate`는 컴포넌트가 마운트되기 전에 처음 실행되므로, `div`의 속성을 읽기 전에 `div`가 존재하는지 확인해야 합니다.