diff --git a/src/content/reference/react-dom/preinit.md b/src/content/reference/react-dom/preinit.md index b4adb40ea..03be1fbb5 100644 --- a/src/content/reference/react-dom/preinit.md +++ b/src/content/reference/react-dom/preinit.md @@ -4,13 +4,13 @@ title: preinit -[React-based frameworks](/learn/start-a-new-react-project) frequently handle resource loading for you, so you might not have to call this API yourself. Consult your framework's documentation for details. +[React 기반 프레임워크](/learn/start-a-new-react-project)는 종종 리소스 로딩을 자동으로 처리하므로, 이 API를 직접 호출하지 않아도 됩니다. 자세한 내용은 사용하는 프레임워크의 문서를 참고하세요. -`preinit` lets you eagerly fetch and evaluate a stylesheet or external script. +`preinit`은 스타일시트나 외부 스크립트를 미리 가져오고 실행할 수 있게 합니다. ```js preinit("https://example.com/script.js", {as: "script"}); @@ -22,11 +22,11 @@ preinit("https://example.com/script.js", {as: "script"}); --- -## Reference {/*reference*/} +## 레퍼런스 {/*reference*/} ### `preinit(href, options)` {/*preinit*/} -To preinit a script or stylesheet, call the `preinit` function from `react-dom`. +스크립트나 스타일시트를 preinit 하려면 `react-dom`에서 `preinit`함수를 호출하세요. ```js import { preinit } from 'react-dom'; @@ -38,42 +38,44 @@ function AppRoot() { ``` -[See more examples below.](#usage) +[아래 예시에서 더 보기.](#usage) -The `preinit` function provides the browser with a hint that it should start downloading and executing the given resource, which can save time. Scripts that you `preinit` are executed when they finish downloading. Stylesheets that you preinit are inserted into the document, which causes them to go into effect right away. +`preinit` 함수는 브라우저에게 주어진 리소스를 다운로드하고 실행하라는 힌트를 제공하여 시간 절약에 도움을 줍니다. `preinit`한 스크립트는 다운로드가 완료되면 즉시 실행됩니다. 스타일시트는 문서에 삽입되어 곧바로 적용됩니다. -#### Parameters {/*parameters*/} +#### 매개변수 {/*parameters*/} -* `href`: a string. The URL of the resource you want to download and execute. -* `options`: an object. It contains the following properties: - * `as`: a required string. The type of resource. Its possible values are `script` and `style`. - * `precedence`: a string. Required with stylesheets. Says where to insert the stylesheet relative to others. Stylesheets with higher precedence can override those with lower precedence. The possible values are `reset`, `low`, `medium`, `high`. - * `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. It is required when `as` is set to `"fetch"`. - * `integrity`: a string. A cryptographic hash of the resource, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). - * `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy. - * `fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are `auto` (the default), `high`, and `low`. +* `href`: 문자열. 다운로드하고 실행할 리소스의 URL입니다. +* `options`: 객체. 다음 속성들을 포함할 수 있습니다: + * `as`: 필수 문자열. 리소스의 유형입니다. 가능한 값은 `script`와 `style`입니다. + * `precedence`: 문자열. 스타일시트에 필수입니다. 다른 스타일시트와의 삽입 순서를 결정합니다. 우선순위가 높은 스타일시트가 낮은 것을 덮어쓸 수 있습니다. 가능한 값은 `reset`, `low`, `medium`, `high`입니다. + * `crossOrigin`: 문자열. 사용할 [CORS 정책](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)입니다. 가능한 값은 `anonymous` 와 `use-credentials`입니다. `as` 가 `"fetch"`일 때 필수입니다. + * `integrity`: 문자열. 리소스의 [무결성을 검증](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)하기 위한 암호화 해시입니다. + * `nonce`: 문자열. 엄격한 콘텐츠 보안 정책을 사용할 때, 리소스를 허용하기 위한 암호화된 [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce)입니다. + * `fetchPriority`: 문자열. 리소스를 가져오는 데 사용할 상대적인 우선순위를 제안합니다. 가능한 값은 `auto` (기본값), `high`, `low`입니다. -#### Returns {/*returns*/} +#### 반환값 {/*returns*/} -`preinit` returns nothing. +`preinit`은 아무것도 반환하지 않습니다. + +#### 주의 사항 {/*caveats*/} + +* 동일한 `href`로 `preinit`을 여러 번 호출해도, 한 번 호출한 것과 동일한 효과만 발생합니다. +* 브라우저에서는 컴포넌트를 렌더링할 때, Effect 내부에서, 이벤트 핸들러 안에서 등 어떤 상황에서든 `preinit`을 호출할 수 있습니다. +* 서버 사이드 렌더링 또는 서버 컴포넌트를 렌더링할 때는, 컴포넌트를 렌더링하면서 또는 컴포넌트 렌더링에서 시작된 비동기 컨텍스트 내에서만 `preinit` 호출이 효과를 가집니다. 그 외의 호출은 무시됩니다. -#### Caveats {/*caveats*/} -* Multiple calls to `preinit` with the same `href` have the same effect as a single call. -* In the browser, you can call `preinit` in any situation: while rendering a component, in an Effect, in an event handler, and so on. -* In server-side rendering or when rendering Server Components, `preinit` only has an effect if you call it while rendering a component or in an async context originating from rendering a component. Any other calls will be ignored. --- -## Usage {/*usage*/} +## 사용법 {/*usage*/} -### Preiniting when rendering {/*preiniting-when-rendering*/} +### 렌더링 시 preinit 하기 {/*preiniting-when-rendering*/} -Call `preinit` when rendering a component if you know that it or its children will use a specific resource, and you're OK with the resource being evaluated and thereby taking effect immediately upon being downloaded. +특정 컴포넌트나 그 자식 컴포넌트가 특정 리소스를 사용할 것을 알고 있고, 해당 리소스가 다운로드되자마자 바로 실행되거나 적용되는 것이 괜찮다면, 컴포넌트를 렌더링할 때 `preinit`을 호출하세요. - + -#### Preiniting an external script {/*preiniting-an-external-script*/} +#### 외부 스크립트 preinit 하기 {/*preiniting-an-external-script*/} ```js import { preinit } from 'react-dom'; @@ -84,11 +86,11 @@ function AppRoot() { } ``` -If you want the browser to download the script but not to execute it right away, use [`preload`](/reference/react-dom/preload) instead. If you want to load an ESM module, use [`preinitModule`](/reference/react-dom/preinitModule). +스크립트를 다운로드하되 즉시 실행하지 않으려면 [`preload`](/reference/react-dom/preload)를 사용하세요. ESM 모듈을 로드하려면 [`preinitModule`](/reference/react-dom/preinitModule)을 사용하세요. -#### Preiniting a stylesheet {/*preiniting-a-stylesheet*/} +#### 스타일시트 preinit 하기 {/*preiniting-a-stylesheet*/} ```js import { preinit } from 'react-dom'; @@ -99,17 +101,17 @@ function AppRoot() { } ``` -The `precedence` option, which is required, lets you control the order of stylesheets within the document. Stylesheets with higher precedence can overrule those with lower precedence. +스타일시트의 삽입 순서를 제어하려면 필수 옵션인 `precedence`를 지정하세요. 우선순위가 높은 스타일시트가 낮은 것을 덮어쓸 수 있습니다. -If you want to download the stylesheet but not to insert it into the document right away, use [`preload`](/reference/react-dom/preload) instead. +스타일시트를 다운로드하되 문서에 바로 삽입하지 않으려면 [`preload`](/reference/react-dom/preload)를 사용하세요. -### Preiniting in an event handler {/*preiniting-in-an-event-handler*/} +### 이벤트 핸들러 내에서 preinit 하기 {/*preiniting-in-an-event-handler*/} -Call `preinit` in an event handler before transitioning to a page or state where external resources will be needed. This gets the process started earlier than if you call it during the rendering of the new page or state. +외부 리소스가 필요한 페이지나 상태로 전환하기 전에 이벤트 핸들러에서 `preinit`을 호출하세요. 이렇게 하면 새 페이지나 상태 렌더링 시점보다 더 일찍 리소스 다운로드가 시작됩니다. ```js import { preinit } from 'react-dom'; diff --git a/src/content/reference/react/useActionState.md b/src/content/reference/react/useActionState.md index 0839e8003..0666ae1ef 100644 --- a/src/content/reference/react/useActionState.md +++ b/src/content/reference/react/useActionState.md @@ -105,16 +105,16 @@ function MyComponent() { `useActionState`가 반환하는 배열은 다음과 같은 요소를 갖습니다. -1. 폼의 현재 State입니다. 처음에는 전달한 초기 State로 설정되며, 폼이 제출된 후에는 전달한 액션의 반환값으로 설정됩니다. -2. `
`의 `action` Prop에 전달할 새로운 액션입니다. +1. 폼의 현재 State는, 처음에는 전달한 초기 State로 설정되며, 폼이 제출된 후에는 전달한 액션의 반환값으로 설정됩니다. +2. ``의 `action` Prop에 전달하거나 `startTransition` 안에서 직접 호출할 수 있는새로운 액션입니다. 3. 액션이 처리되는 동안 사용할 수 있는 대기Pending State입니다. -1. The current state of the form, which is initially set to the initial state you provided, and after the form is submitted is set to the return value of the action you provided. -2. A new action that you pass to `` as its `action` prop or call manually within `startTransition`. -3. A pending state that you can utilise while your action is processing. -폼 제출 시, 액션 함수가 호출되고 그 반환값이 폼의 새로운 현재 State가 됩니다. -또한 액션 함수는 새롭게 추가된 첫 번째 인수로 폼의 현재 State를 받습니다. (처음엔 초기 State, 그 후에는 직전 반환값) 나머지 인수들은 일반 폼 액션 호출과 동일합니다. +폼이 제출되면, 제공한 액션 함수가 호출되며, 해당 함수의 반환값이 새로운 현재 State로 설정됩니다. + +이 액션 함수는 첫 번째 인수로 현재 State를 추가로 전달받습니다. +처음 제출될 때는초기 State가 전달되며, 이후 제출부터는 직전 호출 시 반환된 값이 전달됩니다. 나머지 인수들은 useActionState를 사용하지 않았을 때와 동일합니다. + ```js [[3, 1, "action"], [1, 1, "currentState"]] function action(currentState, formData) {