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
Shallow version of [`ref()`](./reactivity-core.html#ref).
5
+
[`ref()`](./reactivity-core.html#ref)의 얕은 버전입니다.
11
6
12
7
-**타입**:
13
8
@@ -21,29 +16,31 @@ Shallow version of [`ref()`](./reactivity-core.html#ref).
21
16
22
17
-**세부 사항**:
23
18
24
-
Unlike `ref()`, the inner value of a shallow ref is stored and exposed as-is, and will not be made deeply reactive. Only the `.value` access is reactive.
19
+
`ref()`와 달리 `shallowRef()`의 내부 값은 있는 그대로 저장되고 노출되며 내부 깊숙이까지 반응형으로 동작하지는 않습니다.
20
+
`.value` 접근만 반응형입니다.
25
21
26
-
`shallowRef()` is typically used for performance optimizations of large data structures, or integration with external state management systems.
22
+
`shallowRef`는 일반적으로 대규모 데이터 구조의 성능 최적화 또는 외부 상태 관리 시스템과의 통합에 사용됩니다.
27
23
28
24
-**예제**:
29
25
30
26
```js
31
27
conststate=shallowRef({ count:1 })
32
28
33
-
//does NOT trigger change
29
+
//change(변경)을 트리거하지 않음
34
30
state.value.count=2
35
31
36
-
//does trigger change
32
+
//change를 트리거 함
37
33
state.value= { count:2 }
38
34
```
39
35
40
36
-**참고**:
41
-
-[가이드 - Reduce Reactivity Overhead for Large Immutable Structures](/guide/best-practices/performance.html#reduce-reactivity-overhead-for-large-immutable-structures)
42
-
-[가이드 - Integration with External State Systems](/guide/extras/reactivity-in-depth.html#integration-with-external-state-systems)
37
+
-[가이드 - 큰 불변 구조에 대한 반응형 오버헤드 감소](/guide/best-practices/performance.html#reduce-reactivity-overhead-for-large-immutable-structures)
38
+
-[가이드 - 외부 상태 시스템과의 통합](/guide/extras/reactivity-in-depth.html#integration-with-external-state-systems)
43
39
44
40
## triggerRef()
45
41
46
-
Force trigger effects that depends on a [shallow ref](#shallowref). This is typically used after making deep mutations to the inner value of a shallow ref.
42
+
[`shallowRef()`](#shallowref)의 강제 트리거 이펙트.
43
+
이것은 일반적으로 `shallowRef` 내부 깊숙한 곳의 값을 변경 후, 관련 이펙트를 강제로 트리거 하기위해 사용합니다.
47
44
48
45
-**타입**:
49
46
@@ -55,24 +52,24 @@ Force trigger effects that depends on a [shallow ref](#shallowref). This is typi
55
52
56
53
```js
57
54
const shallow = shallowRef({
58
-
greet: 'Hello, world'
55
+
greet: '안녕, Vue!'
59
56
})
60
57
61
-
// Logs "Hello, world" once for the first run-through
58
+
// 첫 실행 시 로그: "안녕, Vue!"
62
59
watchEffect(() => {
63
60
console.log(shallow.value.greet)
64
61
})
65
62
66
-
// This won't trigger the effect because the ref is shallow
@@ -90,13 +87,17 @@ Creates a customized ref with explicit control over its dependency tracking and
90
87
91
88
-**세부 사항**:
92
89
93
-
`customRef()`expectsafactoryfunction, which receives `track` and `trigger` functions as arguments and should return an object with `get` and `set` methods.
90
+
`customRef()`는 인자로 펙토리 함수를 받습니다.
91
+
이 함수는 `track`와 `trigger`를 인자로 수신하며,
92
+
`get`과 `set` 메소드가 포함된 객체를 반환해야 합니다.
94
93
95
-
Ingeneral, `track()`shouldbecalledinside`get()`, and`trigger()`shouldbecalledinside`set()`. However, youhavefullcontroloverwhentheyshouldbecalled, orwhethertheyshouldbecalledatall.
@@ -121,7 +122,7 @@ Creates a customized ref with explicit control over its dependency tracking and
121
122
}
122
123
```
123
124
124
-
Usageincomponent:
125
+
컴포넌트에서 사용법
125
126
126
127
```vue
127
128
<script setup>
@@ -134,11 +135,11 @@ Creates a customized ref with explicit control over its dependency tracking and
134
135
</template>
135
136
```
136
137
137
-
[Try it in the Playground](https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbmltcG9ydCB7IHVzZURlYm91bmNlZFJlZiB9IGZyb20gJy4vZGVib3VuY2VkUmVmLmpzJ1xuY29uc3QgdGV4dCA9IHVzZURlYm91bmNlZFJlZignaGVsbG8nLCAxMDAwKVxuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPHA+XG4gICAgVGhpcyB0ZXh0IG9ubHkgdXBkYXRlcyAxIHNlY29uZCBhZnRlciB5b3UndmUgc3RvcHBlZCB0eXBpbmc6XG4gIDwvcD5cbiAgPHA+e3sgdGV4dCB9fTwvcD5cbiAgPGlucHV0IHYtbW9kZWw9XCJ0ZXh0XCIgLz5cbjwvdGVtcGxhdGU+IiwiaW1wb3J0LW1hcC5qc29uIjoie1xuICBcImltcG9ydHNcIjoge1xuICAgIFwidnVlXCI6IFwiaHR0cHM6Ly9zZmMudnVlanMub3JnL3Z1ZS5ydW50aW1lLmVzbS1icm93c2VyLmpzXCJcbiAgfVxufSIsImRlYm91bmNlZFJlZi5qcyI6ImltcG9ydCB7IGN1c3RvbVJlZiB9IGZyb20gJ3Z1ZSdcblxuZXhwb3J0IGZ1bmN0aW9uIHVzZURlYm91bmNlZFJlZih2YWx1ZSwgZGVsYXkgPSAyMDApIHtcbiAgbGV0IHRpbWVvdXRcbiAgcmV0dXJuIGN1c3RvbVJlZigodHJhY2ssIHRyaWdnZXIpID0+IHtcbiAgICByZXR1cm4ge1xuICAgICAgZ2V0KCkge1xuICAgICAgICB0cmFjaygpXG4gICAgICAgIHJldHVybiB2YWx1ZVxuICAgICAgfSxcbiAgICAgIHNldChuZXdWYWx1ZSkge1xuICAgICAgICBjbGVhclRpbWVvdXQodGltZW91dClcbiAgICAgICAgdGltZW91dCA9IHNldFRpbWVvdXQoKCkgPT4ge1xuICAgICAgICAgIHZhbHVlID0gbmV3VmFsdWVcbiAgICAgICAgICB0cmlnZ2VyKClcbiAgICAgICAgfSwgZGVsYXkpXG4gICAgICB9XG4gICAgfVxuICB9KVxufSJ9)
Theyareconsideredadvancedbecausetherawopt-outisonlyattherootlevel, soifyousetanested, non-markedrawobjectintoareactiveobjectandthenaccessitagain, yougettheproxiedversionback. Thiscanleadto **identityhazards** - i.e. performinganoperationthatreliesonobjectidentitybutusingboththerawandtheproxiedversionofthesameobject:
290
+
원시(raw) 옵트아웃은 루트 레벨에만 있기 때문에 고급으로 간주되므로,
291
+
마크되지 않은 중첩된 원시 객체를 반응형 객체로 설정한 다음 다시 접근을 시도하면,
292
+
프락시 버전의 객체로 접근하게 됩니다.
293
+
이것은 동일한 객체에 참조했다고 예상했으나,
294
+
원시 버전과 프락시 버전을 혼용하여 사용하는 "**잘못된 ID 참조**(identity hazards)"로 이어질 수 있습니다.
269
295
270
296
```js
271
297
const foo = markRaw({
272
298
nested: {}
273
299
})
274
300
275
301
const bar = reactive({
276
-
//although `foo` is marked as raw, foo.nested is not.
302
+
// `foo`는 원시 마크가 있지만, `foo.nested`는 그렇지 않음
277
303
nested: foo.nested
278
304
})
279
305
280
306
console.log(foo.nested === bar.nested) // false
281
307
```
282
308
283
-
Identity hazards are in general rare. However, to properly utilize these APIs while safely avoiding identity hazards requires a solid understanding of how the reactivity system works.
284
-
309
+
잘못된 ID 참조 문제는 일반적으로 드뭅니다.
310
+
그러나 이 문제로부터 안전하게 이러한 API를 활용하려면,
311
+
반응형 시스템이 어떻게 작동하는지에 확실한 이해가 필요합니다.
285
312
:::
286
313
287
314
## effectScope()
288
315
289
-
Creates an effect scope object which can capture the reactive effects (i.e. computed and watchers) created within it so that these effects can be disposed together. For detailed use cases of this API, please consult its corresponding [RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md).
316
+
범위 내 반응형 이펙트(계산된 속성, 감시자)들을 캡처하고,
317
+
일괄적으로 처리하는 effectScope 객체를 반환합니다.
318
+
319
+
이 API의 자세한 사용 사례 참고: [RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md)
290
320
291
321
-**타입**:
292
322
@@ -312,13 +342,13 @@ Creates an effect scope object which can capture the reactive effects (i.e. comp
현재 활성 [effectScope](#effectscope)에 중지(폐기) 콜백을 등록합니다.
362
+
연결된 effectScope이 중지되면 콜백이 호출됩니다.
332
363
333
-
Thismethodcanbeusedasanon-component-coupledreplacementof`onUnmounted`inreusablecompositionfunctions, sinceeachVuecomponent's `setup()` function is also invoked in an effect scope.
364
+
각 Vue 컴포넌트의 `setup()` 함수도 effectScope에서 호출되기 때문에,
365
+
비-컴포넌트-결합(non-component-coupled)에서 재사용 가능한 컴포지션 함수인 `onUnmounted`의 대체로 사용할 수 있습니다.
0 commit comments