Skip to content

Commit bef87c8

Browse files
committed
문서 번역: api/reactivity-utilities.md
1 parent 669f3d3 commit bef87c8

File tree

1 file changed

+40
-30
lines changed

1 file changed

+40
-30
lines changed

ko-KR/src/api/reactivity-utilities.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
:::warning 현재 이 문서는 번역 작업이 진행중입니다
2-
:::
3-
4-
# Reactivity API: Utilities
1+
# 반응형 API: 유틸리티
52

63
## isRef()
74

8-
Checks if a value is a ref object.
5+
값이 ref 객체인지 확인합니다.
96

107
- **타입**:
118

129
```ts
1310
function isRef<T>(r: Ref<T> | unknown): r is Ref<T>
1411
```
1512

16-
Note the return type is a [type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates), which means `isRef` can be used as a type guard:
13+
반환 타입은 [type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)이므로,
14+
`isRef`를 타입 가드로 사용할 수 있습니다.
1715

1816
```ts
1917
let foo: unknown
2018
if (isRef(foo)) {
21-
// foo's type is narrowed to Ref<unknown>
19+
// foo의 타입은 Ref<unknown>으로 한정됨
2220
foo.value
2321
}
2422
```
2523

2624
## unref()
2725

28-
Returns the inner value if the argument is a ref, otherwise return the argument itself. This is a sugar function for `val = isRef(val) ? val.value : val`.
26+
인자가 ref이면 내부 값을 반환하고, 그렇지 않으면 인자 자체를 반환합니다.
27+
이것은 `val = isRef(val) ? val.value : val`과 같습니다.
2928

3029
- **타입**:
3130

@@ -38,13 +37,15 @@ Returns the inner value if the argument is a ref, otherwise return the argument
3837
```ts
3938
function useFoo(x: number | Ref<number>) {
4039
const unwrapped = unref(x)
41-
// unwrapped is guaranteed to be number now
40+
// unwrapped는 이제 확실히 숫자 입니다
4241
}
4342
```
4443

4544
## toRef()
4645

47-
Can be used to create a ref for a property on a source reactive object. The created ref is synced with its source property: mutating the source property will update the ref, and vice-versa.
46+
반응형 객체의 속성에 대한 ref를 만드는 데 사용할 수 있습니다.
47+
생성된 ref는 소스 속성과 동기화됩니다.
48+
소스 속성을 변경하면 ref가 업데이트되고 그 반대의 경우도 마찬가지입니다.
4849

4950
- **타입**:
5051

@@ -68,44 +69,51 @@ Can be used to create a ref for a property on a source reactive object. The crea
6869
6970
const fooRef = toRef(state, 'foo')
7071
71-
// mutating the ref updates the original
72+
// ref를 변경하면 원본도 업데이트 됨
7273
fooRef.value++
7374
console.log(state.foo) // 2
7475
75-
// mutating the original also updates the ref
76+
// 원본을 변경하면 ref도 업데이트 됨
7677
state.foo++
7778
console.log(fooRef.value) // 3
7879
```
7980

80-
Note this is different from:
81+
이것은 다음과 다름에 주의해야 합니다:
8182

8283
```js
8384
const fooRef = ref(state.foo)
8485
```
8586

86-
The above ref is **not** synced with `state.foo`, because the `ref()` receives a plain number value.
87+
위의 ref`state.foo`**동기화되지 않습니다**.
88+
`ref()`가 일반 숫자 값을 수신하기 때문입니다.
8789

88-
`toRef()` is useful when you want to pass the ref of a prop to a composable function:
90+
`toRef()`는 구성화 함수에 propref로 전달하려는 경우에 유용합니다:
8991

9092
```vue
9193
<script setup>
9294
import { toRef } from 'vue'
9395
9496
const props = defineProps(/* ... */)
9597
96-
// convert `props.foo` into a ref, then pass into
97-
// a composable
98+
// `props.foo`를 ref로 변환한 다음 구성화 함수에 전달
9899
useSomeFeature(toRef(props, 'foo'))
99100
</script>
100101
```
101102

102-
When `toRef` is used with component props, the usual restrictions around mutating the props still apply. Attempting to assign a new value to the ref is equivalent to trying to modify the prop directly and is not allowed. In that scenario you may want to consider using [`computed`](./reactivity-core.html#computed) with `get` and `set` instead. See the guide to [using `v-model` with components](/guide/components/events.html#usage-with-v-model) for more information.
103+
`toRef`가 컴포넌트 props와 함께 사용되면,
104+
props 변경에 대한 일반적인 제한 사항이 계속 적용됩니다.
105+
ref에 새 값을 할당하려는 시도는 prop을 직접 수정하려는 것과 동일하며 허용되지 않습니다.
106+
이런 경우에는 [`computed()`](./reactivity-core.html#computed)에 `get``set`을 선언하여 사용하는 것으로 구현할 수 있습니다.
107+
자세한 내용은 [컴포넌트를 `v-model`과 함께 사용하기](/guide/components/events.html#usage-with-v-model) 가이드 참조.
103108

104-
`toRef()` will return a usable ref even if the source property doesn't currently exist. This makes it possible to work with optional properties, which wouldn't be picked up by [`toRefs`](#torefs).
109+
`toRef()`는 소스 속성이 현재 존재하지 않더라도 사용 가능한 ref를 반환합니다.
110+
이렇게 하면 [`toRefs`](#torefs)에서 선택하지 않는 선택적 속성으로 작업할 수 있습니다.
105111

106112
## toRefs()
107113

108-
Converts a reactive object to a plain object where each property of the resulting object is a ref pointing to the corresponding property of the original object. Each individual ref is created using [`toRef()`](#toref).
114+
반응형 객체를 일반 객체로 변환하고,
115+
변환된 일반 객체의 각 속성은 원본 객체(반응형 객체)의 속성이 ref된 것 입니다.
116+
각 개별 ref는 [`toRef()`](#toref)를 사용하여 생성됩니다.
109117

110118
- **타입**:
111119

@@ -129,21 +137,22 @@ Converts a reactive object to a plain object where each property of the resultin
129137
130138
const stateAsRefs = toRefs(state)
131139
/*
132-
Type of stateAsRefs: {
140+
stateAsRefs의 타입: {
133141
foo: Ref<number>,
134142
bar: Ref<number>
135143
}
136144
*/
137145
138-
// The ref and the original property is "linked"
146+
// 원본 속성이 ref와 "연결됨"
139147
state.foo++
140148
console.log(stateAsRefs.foo.value) // 2
141149
142150
stateAsRefs.foo.value++
143151
console.log(state.foo) // 3
144152
```
145153

146-
`toRefs` is useful when returning a reactive object from a composable function so that the consuming component can destructure/spread the returned object without losing reactivity:
154+
`toRefs`는 구성화 함수에서 반응형 객체를 반환하면,
155+
이것을 사용하는 컴포넌트가 반응형을 잃지 않고 분해 할당 및 확장 할 수 있어 유용합니다.
147156

148157
```js
149158
function useFeatureX() {
@@ -152,21 +161,22 @@ Converts a reactive object to a plain object where each property of the resultin
152161
bar: 2
153162
})
154163
155-
// ...logic operating on state
164+
// ...state를 사용하여 작동하는 로직
156165
157-
// convert to refs when returning
166+
// 반환할 때 refs로 변환
158167
return toRefs(state)
159168
}
160169
161-
// can destructure without losing reactivity
170+
// 반응형을 잃지 않고 분해 할당 가능
162171
const { foo, bar } = useFeatureX()
163172
```
164173

165-
`toRefs` will only generate refs for properties that are enumerable on the source object at call time. To create a ref for a property that may not exist yet, use [`toRef`](#toref) instead.
174+
`toRefs`는 호출 시 소스 객체에서 열거 가능한 속성만 참조로 생성합니다.
175+
아직 존재하지 않을 수 있는 속성에 대한 참조를 생성하려면 [`toRef`](#toref)를 사용해야 합니다.
166176

167177
## isProxy()
168178

169-
Checks if an object is a proxy created by [`reactive()`](./reactivity-core.html#reactive), [`readonly()`](./reactivity-core.html#readonly), [`shallowReactive()`](./reactivity-advanced.html#shallowreactive) or [`shallowReadonly()`](./reactivity-advanced.html#shallowreadonly).
179+
객체가 [`reactive()`](./reactivity-core.html#reactive), [`readonly()`](./reactivity-core.html#readonly), [`shallowReactive()`](./reactivity-advanced.html#shallowreactive) 또는 [`shallowReadonly()`](./reactivity-advanced.html#shallowreadonly)에 의해 생성된 프락시인지 확인합니다.
170180

171181
- **타입**:
172182

@@ -176,7 +186,7 @@ Checks if an object is a proxy created by [`reactive()`](./reactivity-core.html#
176186

177187
## isReactive()
178188

179-
Checks if an object is a proxy created by [`reactive()`](./reactivity-core.html#reactive) or [`shallowReactive()`](./reactivity-advanced.html#shallowreactive).
189+
객체가 [`reactive()`](./reactivity-core.html#reactive) 또는 [`shallowReactive()`](./reactivity-advanced.html#shallowreactive)에 의해 생성된 프락시인지 확인합니다.
180190

181191
- **타입**:
182192

@@ -186,7 +196,7 @@ Checks if an object is a proxy created by [`reactive()`](./reactivity-core.html#
186196

187197
## isReadonly()
188198

189-
Checks if an object is a proxy created by [`readonly()`](./reactivity-core.html#readonly) or [`shallowReadonly()`](./reactivity-advanced.html#shallowreadonly).
199+
객체가 [`readonly()`](./reactivity-core.html#readonly) 또는 [`shallowReadonly()`](./reactivity-advanced.html#shallowreadonly)에 의해 생성된 프락시인지 확인합니다.
190200

191201
- **타입**:
192202

0 commit comments

Comments
 (0)