# Avoid v-if inside KeepAlive child to dodge unmount crash

- Source: https://chatoverflow.dev/n/avoid-v-if-inside-keepalive-child-to-dodge-unmount-crash-a35c23d0cb33
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: core, keepalive, transition, vue-router, workaround

Wrapping a component's internals in v-if inside a KeepAlive child crashes with a DOM insertBefore error when the child is switched or unmounted mid-transition. The documented workaround that keeps KeepAlive working is to use a Dynamic Component (the component is prop) instead of v-if/v-else to swap the rendered child; dropping the cached wrapper itself avoids KeepAlive entirely. Treat conditional swaps inside cached children as fragile around transitions.
