Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
72 changes: 35 additions & 37 deletions src/content/reference/react/addTransitionType.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ version: experimental

<Experimental>

**This API is experimental and is not available in a stable version of React yet.**
**이 API는 실험적이며 React 안정 버전에서는 아직 사용할 수 없습니다.**

You can try it by upgrading React packages to the most recent experimental version:
이 API를 사용하려면 React 패키지를 가장 최신의 실험적인 버전으로 업그레이드해야 합니다.

- `react@experimental`
- `react-dom@experimental`
- `eslint-plugin-react-hooks@experimental`

Experimental versions of React may contain bugs. Don't use them in production.
실험적인 버전의 React에는 버그가 있을 수 있습니다. 프로덕션에서는 사용하지 마세요.

</Experimental>

<Intro>

`unstable_addTransitionType` lets you specify the cause of a transition.

`unstable_addTransitionType`를 사용하면 트랜지션이 발생한 원인을 상세히 나타낼 수 있습니다.

```js
startTransition(() => {
Expand All @@ -35,32 +34,32 @@ startTransition(() => {

---

## Reference {/*reference*/}
## 레퍼런스 {/*reference*/}

### `addTransitionType` {/*addtransitiontype*/}

#### Parameters {/*parameters*/}
#### 매개변수 {/*parameters*/}

- `type`: The type of transition to add. This can be any string.
- `type`: 추가할 트랜지션의 타입입니다. 어떤 문자열이든 될 수 있습니다.

#### Returns {/*returns*/}
#### 반환값 {/*returns*/}

`startTransition` does not return anything.
`startTransition`은 아무것도 반환하지 않습니다.

#### Caveats {/*caveats*/}
#### 주의 사항 {/*caveats*/}

- If multiple transitions are combined, all Transition Types are collected. You can also add more than one type to a Transition.
- Transition Types are reset after each commit. This means a `<Suspense>` fallback will associate the types after a `startTransition`, but revealing the content does not.
- 여러 트랜지션이 결합되면 모든 트랜지션 타입이 수집됩니다. 하나의 트랜지션에 두 개 이상의 타입을 추가할 수도 있습니다.
- 트랜지션 타입은 커밋마다 초기화됩니다. 즉, `<Suspense>`의 Fallback은 `startTransition` 이후 타입을 연결하며, 내용이 나타날 때는 그렇지 않습니다.

---

## Usage {/*usage*/}
## 사용법 {/*usage*/}

### Adding the cause of a transition {/*adding-the-cause-of-a-transition*/}
### 트랜지션의 원인 추가하기 {/*adding-the-cause-of-a-transition*/}

Call `addTransitionType` inside of `startTransition` to indicate the cause of a transition:
`startTransition` 내부에서 `addTransitionType`을 호출해 트랜지션의 원인을 나타냅니다.

``` [[1, 6, "unstable_addTransitionType"], [2, 5, "startTransition", [3, 6, "'submit-click'"]]
```
import { startTransition, unstable_addTransitionType } from 'react';

function Submit({action) {
Expand All @@ -76,22 +75,21 @@ function Submit({action) {

```

When you call <CodeStep step={1}>addTransitionType</CodeStep> inside the scope of <CodeStep step={2}>startTransition</CodeStep>, React will associate <CodeStep step={3}>submit-click</CodeStep> as one of the causes for the Transition.

Currently, Transition Types can be used to customize different animations based on what caused the Transition. You have three different ways to choose from for how to use them:
<CodeStep step={1}>addTransitionType</CodeStep>을 <CodeStep step={2}>startTransition</CodeStep>의 범위 내에서 호출하면, React는 해당 트랜지션에 <CodeStep step={3}>submit-click</CodeStep>을 원인으로 연결합니다.

- [Customize animations using browser view transition types](#customize-animations-using-browser-view-transition-types)
- [Customize animations using `View Transition` Class](#customize-animations-using-view-transition-class)
- [Customize animations using `ViewTransition` events](#customize-animations-using-viewtransition-events)
현재 트랜지션 타입은 원인에 따라 서로 다른 애니메이션을 커스터마이즈하는 데 사용할 수 있습니다. 사용할 수 있는 방식은 세 가지입니다:
- [브라우저 view transition 타입으로 애니메이션 커스텀하기](#customize-animations-using-browser-view-transition-types)
- [`View Transition` 클래스로 애니메이션 커스텀하기](#customize-animations-using-view-transition-class)
- [`ViewTransition`이벤트로 애니메이션 커스텀하기](#customize-animations-using-viewtransition-events)

In the future, we plan to support more use cases for using the cause of a transition.
향후에는 트랜지션의 원인을 활용할 수 있는 다양한 용례를 지원할 예정입니다.

---
### Customize animations using browser view transition types {/*customize-animations-using-browser-view-transition-types*/}
### 브라우저 view transition 타입으로 애니메이션 커스텀하기 {/*customize-animations-using-browser-view-transition-types*/}

When a [`ViewTransition`](/reference/react/ViewTransition) activates from a transition, React adds all the Transition Types as browser [view transition types](https://www.w3.org/TR/css-view-transitions-2/#active-view-transition-pseudo-examples) to the element.
트랜지션에서 [`ViewTransition`](/reference/react/ViewTransition)이 활성화되면, React는 모든 트랜지션 타입을 브라우저의 [view transition types](https://www.w3.org/TR/css-view-transitions-2/#active-view-transition-pseudo-examples)으로 해당 요소에 추가합니다.

This allows you to customize different animations based on CSS scopes:
이렇게 하면 CSS 범위에서 다른 애니메이션을 커스텀할 수 있습니다.

```js [11]
function Component() {
Expand All @@ -118,9 +116,10 @@ startTransition(() => {

---

### Customize animations using `View Transition` Class {/*customize-animations-using-view-transition-class*/}
### `View Transition` 클래스로 애니메이션 커스텀하기 {/*customize-animations-using-view-transition-class*/}

활성화된 ViewTransition에서 타입에 따라 애니메이션을 커스터마이즈하려면, View Transition 클래스에 객체를 전달하면 됩니다.

You can customize animations for an activated `ViewTransition` based on type by passing an object to the View Transition Class:

```js
function Component() {
Expand All @@ -140,9 +139,9 @@ startTransition(() => {
});
```

If multiple types match, then they're joined together. If no types match then the special "default" entry is used instead. If any type has the value "none" then that wins and the ViewTransition is disabled (not assigned a name).
여러 타입이 매칭되면 값들이 결합되고, 매칭되는 타입이 없으면 "default" 엔트리가 사용됩니다. 만약 값이 "none"이면 ViewTransition이 비활성화되어 이름이 할당되지 않습니다.

These can be combined with enter/exit/update/layout/share props to match based on kind of trigger and Transition Type.
이 방식은 enter/exit/update/layout/share props와 결합하여 트리거 종류와 트랜지션 타입에 따라 동작을 맞출 수 있습니다.

```js
<ViewTransition enter={{
Expand All @@ -157,9 +156,9 @@ exit={{

---

### Customize animations using `ViewTransition` events {/*customize-animations-using-viewtransition-events*/}
### `ViewTransition`이벤트로 애니메이션 커스텀하기 {/*customize-animations-using-viewtransition-events*/}

You can imperatively customize animations for an activated `ViewTransition` based on type using View Transition events:
View Transition 이벤트를 활용하여 타입에 따라 활성화된 `ViewTransition`의 애니메이션을 즉시 커스터마이즈할 수 있습니다.

```
<ViewTransition onUpdate={(inst, types) => {
Expand All @@ -172,11 +171,10 @@ You can imperatively customize animations for an activated `ViewTransition` base
}
}}>
```

This allows you to pick different imperative Animations based on the cause.
이렇게 하면 원인에 따라 서로 다른 애니메이션을 선택할 수 있습니다.

---

## Troubleshooting {/*troubleshooting*/}
## 문제 해결 {/*troubleshooting*/}

### TODO {/*todo2*/}
### 해야 할 일 {/*todo2*/}
19 changes: 12 additions & 7 deletions src/content/reference/react/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ title: "내장 React API"
[Hook](/reference/react/hooks)과 [컴포넌트](/reference/react/components) 외에도 `react` 패키지는 컴포넌트를 정의하는데 유용한 몇 가지 API를 가지고 있습니다. 이 페이지는 최신 React API를 모두 나열합니다.

</Intro>
{/*React 영문 공식 문서에 반영되지 않은 내용 임의로 수정하여 반영하였습니다. `cahce` 및 `use`에 대한 내용 설명을 제외하고 수정하지 말아주세요*/}

{/*React 영문 공식 문서에 반영되지 않은 내용 임의로 수정하여 반영하였습니다. `cache` 및 `use`에 대한 내용 설명을 제외하고 수정하지 말아주세요*/}

---
* [`act`](/reference/react/act) lets you wrap renders and interactions in tests to ensure updates have processed before making assertions.
* [`act`](/reference/react/act)를 통해 테스트에서 렌더링이나 상호작용을 감싸서 관련된 업데이트가 모두 처리된 뒤에 검증합니다.
* [`cache`](/reference/react/cache)를 통해 가져온 데이터나 연산의 결과를 캐싱합니다.
* [`createContext`](/reference/react/createContext) lets you define and provide context to the child components. Used with [`useContext`.](/reference/react/useContext)
* [`lazy`](/reference/react/lazy) lets you defer loading a component's code until it's rendered for the first time.
* [`memo`](/reference/react/memo) lets your component skip re-renders with same props. Used with [`useMemo`](/reference/react/useMemo) and [`useCallback`.](/reference/react/useCallback)
* [`startTransition`](/reference/react/startTransition) lets you mark a state update as non-urgent. Similar to [`useTransition`.](/reference/react/useTransition)
* [`use`](/reference/react/use)는 Promise나 Context와 같은 데이터를 참조하는 React Hook입니다.
* [`captureOwnerStack`](/reference/react/captureOwnerStack)를 통해 개발 환경에서 현재 Owner Stack을 읽고, 사용가능한 문자열을 반환합니다.
* [`createContext`](/reference/react/createContext)를 통해 자식 컴포넌트들에게 전달할 수 있는 컨텍스트를 정의하고 제공합니다. 보통 [`useContext`](/reference/react/useContext)와 함께 씁니다.
* [`lazy`](/reference/react/lazy)를 통해 컴포넌트가 처음 렌더링될 때까지 해당 컴포넌트의 코드를 로딩하는 것을 지연합니다.
* [`memo`](/reference/react/memo)를 통해 동일한 props일 경우 컴포넌트가 다시 렌더링되지 않도록 최적화합니다. 주로 [`useMemo`](/reference/react/useMemo), [`useCallback`](/reference/react/useCallback)과 함께 사용됩니다.
* [`startTransition`](/reference/react/startTransition)를 통해 상태 업데이트를 “덜 긴급한 작업”으로 표시하여 UI의 반응성을 유지합니다. [`useTransition`](/reference/react/useTransition)과 유사합니다.
* [`taintObjectReference`](/reference/react/experimental_taintObjectReference)를 통해 `user` 객체와 같은 특정한 객체 인스턴스를 클라이언트 컴포넌트로 전송하는 것을 방지합니다.
* [`taintUniqueValue`](/reference/react/experimental_taintUniqueValue)를 통해 패스워드, 키 또는 토큰과 같은 고유 값을 클라이언트 컴포넌트로 전송하는 것을 방지합니다.
* [`addTransitionType`](/reference/react/addTransitionType)를 통해, 트랜지션이 발생한 원인을 상세히 나타냅니다.
---

## Resource APIs {/*resource-apis*/}
Expand Down
64 changes: 31 additions & 33 deletions src/content/reference/react/captureOwnerStack.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: captureOwnerStack

<Intro>

`captureOwnerStack` reads the current Owner Stack in development and returns it as a string if available.
`captureOwnerStack`는 개발 환경에서 현재 Owner Stack을 읽고, 사용할 수 있는 문자열을 반환합니다.

```js
const stack = captureOwnerStack();
Expand All @@ -16,11 +16,11 @@ const stack = captureOwnerStack();

---

## Reference {/*reference*/}
## 레퍼런스 {/*reference*/}

### `captureOwnerStack()` {/*captureownerstack*/}

Call `captureOwnerStack` to get the current Owner Stack.
`captureOwnerStack`을 호출하여 현재 Owner Stack을 가져옵니다.

```js {5,5}
import * as React from 'react';
Expand All @@ -33,33 +33,33 @@ function Component() {
}
```

#### Parameters {/*parameters*/}
#### 매개변수 {/*parameters*/}

`captureOwnerStack` does not take any parameters.
`captureOwnerStack`는 매개변수를 받지 않습니다.

#### Returns {/*returns*/}
#### 반환값 {/*returns*/}

`captureOwnerStack` returns `string | null`.
`captureOwnerStack``string`이나 `null`을 반환합니다.

Owner Stacks are available in
- Component render
- Effects (e.g. `useEffect`)
- React's event handlers (e.g. `<button onClick={...} />`)
- React error handlers ([React Root options](/reference/react-dom/client/createRoot#parameters) `onCaughtError`, `onRecoverableError`, and `onUncaughtError`)
Owner Stacks은 다음 경우에 사용할 수 있습니다.
- 컴포넌트 렌더링 시
- 이펙트 (예: `useEffect`)
- React 이벤트 핸들러 (예: `<button onClick={...} />`)
- React 에러 핸들러 ([React 루트 옵션](/reference/react-dom/client/createRoot#parameters) `onCaughtError`, `onRecoverableError`, `onUncaughtError`)

If no Owner Stack is available, `null` is returned (see [Troubleshooting: The Owner Stack is `null`](#the-owner-stack-is-null)).
Owner Stack을 사용할 수 없는 경우, `null`이 반환됩니다. ([문제해결: Owner Stack이 `null`인 경우](#the-owner-stack-is-null))

#### Caveats {/*caveats*/}
#### 주의 사항 {/*caveats*/}

- Owner Stacks are only available in development. `captureOwnerStack` will always return `null` outside of development.
- Owner Stack은 개발 환경에서만 사용할 수 있습니다. `captureOwnerStack`은 개발 환경 밖에서는 항상 `null`을 반환합니다.

<DeepDive>

#### Owner Stack vs Component Stack {/*owner-stack-vs-component-stack*/}

The Owner Stack is different from the Component Stack available in React error handlers like [`errorInfo.componentStack` in `onUncaughtError`](/reference/react-dom/client/hydrateRoot#show-a-dialog-for-uncaught-errors).
Owner Stack은 [`errorInfo.componentStack` in `onUncaughtError`](/reference/react-dom/client/hydrateRoot#show-a-dialog-for-uncaught-errors)와 같은 리액트 에러 핸들러에서 사용할 수 있는 Component Stack과 다릅니다.

For example, consider the following code:
예를 들어 다음 코드를 살펴보겠습니다.

<Sandpack>

Expand Down Expand Up @@ -136,8 +136,7 @@ createRoot(document.createElement('div'), {

</Sandpack>

`SubComponent` would throw an error.
The Component Stack of that error would be
`SubComponent`에서 에러가 날 때, 에러의 Component Stack은 다음과 같을 수 있습니다.

```
at SubComponent
Expand All @@ -147,24 +146,23 @@ at main
at React.Suspense
at App
```

However, the Owner Stack would only read
그러나 Owner Stack은 이렇게만 읽습니다.

```
at Component
```

Neither `App` nor the DOM components (e.g. `fieldset`) are considered Owners in this Stack since they didn't contribute to "creating" the node containing `SubComponent`. `App` and DOM components only forwarded the node. `App` just rendered the `children` node as opposed to `Component` which created a node containing `SubComponent` via `<SubComponent />`.
`App`이나 DOM 컴포넌트들(예: `fieldset`)은 이 스택에 포함되지 않습니다. 왜냐하면 이들은 `SubComponent`를 포함하는 노드를 "생성하는" 데에 기여하지 않기 때문입니다. `App`DOM 컴포넌트들은 노드를 전달할 뿐입니다. `App`은 `<SubComponent />`를 통해 `SubComponent`를 포함한 노드를 생성하는 `Component`와 달리 `children` 노드만 렌더링합니다.

Neither `Navigation` nor `legend` are in the stack at all since it's only a sibling to a node containing `<SubComponent />`.
또한, `Navigation`이나 `legend`도 `<SubComponent />`를 포함하는 노드의 형제가 아니기 때문에, 스택에 없습니다.

`SubComponent` is omitted because it's already part of the callstack.
`SubComponent`는 이미 호출 스택에 포함되어 있어서 Owner Stack에 나오지 않습니다.

</DeepDive>

## Usage {/*usage*/}
## 사용법 {/*usage*/}

### Enhance a custom error overlay {/*enhance-a-custom-error-overlay*/}
### 커스텀 에러 오버레이 개선하기 {/*enhance-a-custom-error-overlay*/}

```js [[1, 5, "console.error"], [4, 7, "captureOwnerStack"]]
import { captureOwnerStack } from "react";
Expand All @@ -183,7 +181,7 @@ console.error = function patchedConsoleError(...args) {
};
```

If you intercept <CodeStep step={1}>`console.error`</CodeStep> calls to highlight them in an error overlay, you can call <CodeStep step={2}>`captureOwnerStack`</CodeStep> to include the Owner Stack.
<CodeStep step={1}>`console.error`</CodeStep> 호출을 가로채서 에러 오버레이에 표시하고 싶다면, <CodeStep step={2}>`captureOwnerStack`</CodeStep>을 호출하여 `OwnerStack`을 포함할 수 있습니다.

<Sandpack>

Expand Down Expand Up @@ -347,13 +345,13 @@ export default function App() {

</Sandpack>

## Troubleshooting {/*troubleshooting*/}
## 문제 해결 {/*troubleshooting*/}

### The Owner Stack is `null` {/*the-owner-stack-is-null*/}
### Owner Stack이 `null`인 경우 {/*the-owner-stack-is-null*/}

The call of `captureOwnerStack` happened outside of a React controlled function e.g. in a `setTimeout` callback, after a `fetch` call or in a custom DOM event handler. During render, Effects, React event handlers, and React error handlers (e.g. `hydrateRoot#options.onCaughtError`) Owner Stacks should be available.
`captureOwnerStack`이 React가 제어하지 않는 함수 바깥에서 호출됐을 경우, 예를 들어 `setTimeout` 콜백, `fetch` 호출 후, 커스텀 DOM 이벤트 핸들러 등에서는 Owner Stack이 null이 됩니다. 렌더링 중이나 이펙트, React 이벤트 핸들러, React 에러 핸들러(예: `hydrateRoot#options.onCaughtError`) 내에서만 생성됩니다.

In the example below, clicking the button will log an empty Owner Stack because `captureOwnerStack` was called during a custom DOM event handler. The Owner Stack must be captured earlier e.g. by moving the call of `captureOwnerStack` into the Effect body.
아래 예시에서, 버튼을 클릭하면 빈 Owner Stack이 로그로 출력됩니다. 그 이유는 `captureOwnerStack`이 커스텀 이벤트 핸들러 내에서 호출되었기 때문입니다. Owner Stack은 더 이른 시점, 예를 들어 이펙트 내부에서 `captureOwnerStack`를 호출하도록 이동시켜야 올바르게 캡처할 수 있습니다.
<Sandpack>

```js
Expand Down Expand Up @@ -381,9 +379,9 @@ export default function App() {

</Sandpack>

### `captureOwnerStack` is not available {/*captureownerstack-is-not-available*/}
### `captureOwnerStack`을 사용할 수 없는 경우 {/*captureownerstack-is-not-available*/}

`captureOwnerStack` is only exported in development builds. It will be `undefined` in production builds. If `captureOwnerStack` is used in files that are bundled for production and development, you should conditionally access it from a namespace import.
`captureOwnerStack`은 개발 환경 빌드에서만 export됩니다. 프로덕션 환경 빌드에서는 `undefined`입니다. `captureOwnerStack`이 개발과 프로덕션이 모두 번들링되는 파일에서 사용될 때는 네임스페이스 import를 사용하고 조건부로 접근해야 합니다.

```js
// Don't use named imports of `captureOwnerStack` in files that are bundled for development and production.
Expand Down