티스토리 뷰
Vue 에러 [Vue warn]: Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with `markRaw` or using `shallowRef` instead ..
실전압축코딩 2023. 6. 19. 09:29vue에서는 컴포넌트를 동적으로 사용할수 있는 기능이 있다.
객체를 생성해 프로퍼티의 value에 컴포넌트를 할당해 동적으로 컴포넌트를 사용하고자 했다.
<template>
<component :is="el.component" />
</template>
...
import Ex from "@/views/Ex.vue";
const el = {
component: Ex
}
이런식으로...
그런데 작동은 잘 되지만, warn이 엄청나게 나왔다!

원인을 대략 확인해 보니 경고 메시지 그대로, 반응성 객체로 만들어진 구성요소는 성능에 오버헤드를 초래 한다는 것이였다.
구글링 해본 결과 stack overflow에서 해결 방법을 찾았다.
https://stackoverflow.com/questions/65716637/vue3-performance-warning-using-ref
vue3 performance warning using ref
vue is throwing this message: Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with mark...
stackoverflow.com
객체를 '원시'로 표시하는 markRow 함수를 사용하거나, 대규모 데이터 구조의 성능 최적화 또는 외부 상태 관리 시스템과의 통합에 사용되는 shallowRef 함수를 사용 해야 한다.
<template>
<component :is="el.component" />
</template>
...
import { shallowRef } from "vue";
import Ex from "@/views/Ex.vue";
const el = {
component: shallowRef(Ex),
}
markRow와 shallowRef
https://vuejs.org/api/reactivity-advanced.html#shallowreadonly
Reactivity API: Advanced | Vue.js
vuejs.org
'프론트엔드 > Vue.js' 카테고리의 다른 글
[Vue] 기존에 생성된 Vue 앱의 route에 엑세스 하기 (0) | 2023.04.21 |
---|---|
[TS] 느낌표(!) non-null 단어 연산자 ( Object is possibly undefined 에러) (0) | 2022.11.18 |
[Vue3] 로그인 창 만들기 + 아이디, 비밀번호 유효성 검증 (vuetify3 v-text-field + typescript) (0) | 2022.11.09 |
Failed to load config "@vue/standard" to extend from. (0) | 2022.11.08 |
vuetify icon 확인 사이트 (0) | 2022.11.03 |
- Total
- Today
- Yesterday
- vue
- vue ref
- eslint
- 394. decode string js
- next.js import glsl
- react 3d
- 394. decode string javascript
- webpack glsl
- react three fiber leva
- ts glsl
- react 3d animation
- react glsl
- vue3
- react fiber 3d
- vue react
- react leva
- react 3d text
- react 3d 에니메이션
- Vue.js
- [leetcode] 394. decode string
- [leetcode] 394. decode string js
- leva
- typescript gsls
- attempted import error: bvh_struct_definitions' is not exported from './gpu/bvhshaderglsl.js' (imported as 'bvhshaderglsl').
- 394 decode string
- react ref reative
- react vue
- three.js leva
- react three fiber
- vue reactive
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |