You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ko-KR/src/api/reactivity-utilities.md
+40-30Lines changed: 40 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,30 @@
1
-
:::warning 현재 이 문서는 번역 작업이 진행중입니다
2
-
:::
3
-
4
-
# Reactivity API: Utilities
1
+
# 반응형 API: 유틸리티
5
2
6
3
## isRef()
7
4
8
-
Checks if a value is a ref object.
5
+
값이 ref 객체인지 확인합니다.
9
6
10
7
-**타입**:
11
8
12
9
```ts
13
10
function isRef<T>(r:Ref<T> |unknown):risRef<T>
14
11
```
15
12
16
-
Notethereturntypeisa [typepredicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates), which means `isRef` can be used as a type guard:
@@ -38,13 +37,15 @@ Returns the inner value if the argument is a ref, otherwise return the argument
38
37
```ts
39
38
function useFoo(x: number | Ref<number>) {
40
39
const unwrapped = unref(x)
41
-
//unwrapped is guaranteed to be number now
40
+
// unwrapped는 이제 확실히 숫자 입니다
42
41
}
43
42
```
44
43
45
44
## toRef()
46
45
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가 업데이트되고 그 반대의 경우도 마찬가지입니다.
48
49
49
50
-**타입**:
50
51
@@ -68,44 +69,51 @@ Can be used to create a ref for a property on a source reactive object. The crea
68
69
69
70
const fooRef = toRef(state, 'foo')
70
71
71
-
//mutating the ref updates the original
72
+
// ref를 변경하면 원본도 업데이트 됨
72
73
fooRef.value++
73
74
console.log(state.foo) // 2
74
75
75
-
//mutating the original also updates the ref
76
+
// 원본을 변경하면 ref도 업데이트 됨
76
77
state.foo++
77
78
console.log(fooRef.value) // 3
78
79
```
79
80
80
-
Note this is different from:
81
+
이것은 다음과 다름에 주의해야 합니다:
81
82
82
83
```js
83
84
const fooRef = ref(state.foo)
84
85
```
85
86
86
-
The above ref is **not** synced with `state.foo`, because the `ref()` receives a plain number value.
87
+
위의 ref는 `state.foo`와 **동기화되지 않습니다**.
88
+
`ref()`가 일반 숫자 값을 수신하기 때문입니다.
87
89
88
-
`toRef()` is useful when you want to pass the ref of a prop to a composable function:
90
+
`toRef()`는 구성화 함수에 prop을 ref로 전달하려는 경우에 유용합니다:
89
91
90
92
```vue
91
93
<script setup>
92
94
import { toRef } from 'vue'
93
95
94
96
const props = defineProps(/* ... */)
95
97
96
-
// convert `props.foo` into a ref, then pass into
97
-
// a composable
98
+
// `props.foo`를 ref로 변환한 다음 구성화 함수에 전달
98
99
useSomeFeature(toRef(props, 'foo'))
99
100
</script>
100
101
```
101
102
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) 가이드 참조.
103
108
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)에서 선택하지 않는 선택적 속성으로 작업할 수 있습니다.
105
111
106
112
## toRefs()
107
113
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)를 사용하여 생성됩니다.
109
117
110
118
-**타입**:
111
119
@@ -129,21 +137,22 @@ Converts a reactive object to a plain object where each property of the resultin
129
137
130
138
const stateAsRefs = toRefs(state)
131
139
/*
132
-
Type of stateAsRefs: {
140
+
stateAsRefs의 타입: {
133
141
foo: Ref<number>,
134
142
bar: Ref<number>
135
143
}
136
144
*/
137
145
138
-
//The ref and the original property is "linked"
146
+
// 원본 속성이 ref와 "연결됨"
139
147
state.foo++
140
148
console.log(stateAsRefs.foo.value) // 2
141
149
142
150
stateAsRefs.foo.value++
143
151
console.log(state.foo) // 3
144
152
```
145
153
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
+
이것을 사용하는 컴포넌트가 반응형을 잃지 않고 분해 할당 및 확장 할 수 있어 유용합니다.
147
156
148
157
```js
149
158
function useFeatureX() {
@@ -152,21 +161,22 @@ Converts a reactive object to a plain object where each property of the resultin
152
161
bar: 2
153
162
})
154
163
155
-
// ...logic operating on state
164
+
// ...state를 사용하여 작동하는 로직
156
165
157
-
//convert to refs when returning
166
+
// 반환할 때 refs로 변환
158
167
return toRefs(state)
159
168
}
160
169
161
-
//can destructure without losing reactivity
170
+
// 반응형을 잃지 않고 분해 할당 가능
162
171
const { foo, bar } = useFeatureX()
163
172
```
164
173
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)를 사용해야 합니다.
166
176
167
177
## isProxy()
168
178
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)에 의해 생성된 프락시인지 확인합니다.
170
180
171
181
-**타입**:
172
182
@@ -176,7 +186,7 @@ Checks if an object is a proxy created by [`reactive()`](./reactivity-core.html#
176
186
177
187
## isReactive()
178
188
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)에 의해 생성된 프락시인지 확인합니다.
180
190
181
191
-**타입**:
182
192
@@ -186,7 +196,7 @@ Checks if an object is a proxy created by [`reactive()`](./reactivity-core.html#
186
196
187
197
## isReadonly()
188
198
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)에 의해 생성된 프락시인지 확인합니다.
0 commit comments