惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
月光博客
月光博客
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
小众软件
小众软件
量子位
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Vue Teleport component React: How does VuReact convert it?
Ryan John · 2026-05-31 · via DEV Community

Ryan John

VuReact is a compiler toolchain for migrating from Vue to React — and for writing React with Vue 3 syntax. In this article, we dive straight into the core: how Vue's built-in <Teleport> component is compiled into React code by VuReact.

Before We Start

To keep the examples easy to read, this article follows two simple conventions:

  1. All Vue and React snippets focus on core logic only, with full component wrappers and unrelated configuration omitted.
  2. The discussion assumes you are already familiar with Vue 3's <Teleport> component usage.

Compilation Mapping

Teleport: Portal component

<Teleport> is Vue's built-in component for rendering component content to other locations in the DOM tree. It is commonly used for modals, notifications, overlays, and other scenarios where content needs to be rendered outside the current component hierarchy.

Basic Teleport usage

  • Vue
<template>
  <Teleport to="body">
    <Modal />
  </Teleport>
</template>

Enter fullscreen mode Exit fullscreen mode

  • Compiled React
import { Teleport } from '@vureact/runtime-core';

<Teleport to="body">
  <Modal />
</Teleport>

Enter fullscreen mode Exit fullscreen mode

As the example shows, Vue's <Teleport> component is compiled into the Teleport adapter component provided by VuReact Runtime — think of it as "Vue's Teleport for React".

The key characteristics of this compilation approach are:

  1. Semantic consistency: Fully simulates Vue <Teleport> behavior by implementing content teleportation
  2. DOM manipulation: Renders child content to the specified DOM location
  3. React integration: Implements teleportation within React's virtual DOM system
  4. Performance optimization: Intelligently manages DOM node mounting and unmounting

Disabling teleportation

The disabled attribute can temporarily disable teleportation, causing the content to render in its original location.

  • Vue
<template>
  <Teleport to="body" :disabled="isMobile">
    <Notification />
  </Teleport>
</template>

Enter fullscreen mode Exit fullscreen mode

  • Compiled React
<Teleport to="body" disabled={isMobile}>
  <Notification />
</Teleport>

Enter fullscreen mode Exit fullscreen mode


Multiple Teleports to the same target

Multiple <Teleport> components can point to the same target container. Content is appended in render order.

  • Vue
<template>
  <Teleport to="#modal-container">
    <ModalA />
  </Teleport>

  <Teleport to="#modal-container">
    <ModalB />
  </Teleport>
</template>

Enter fullscreen mode Exit fullscreen mode

  • Compiled React
<Teleport to="#modal-container">
  <ModalA />
</Teleport>

<Teleport to="#modal-container">
  <ModalB />
</Teleport>

Enter fullscreen mode Exit fullscreen mode


Deferred teleportation

The defer attribute can delay teleportation until after the component is fully mounted.

  • Vue
<template>
  <Teleport to="#dynamic-container" :defer="true">
    <DynamicContent />
  </Teleport>
</template>

Enter fullscreen mode Exit fullscreen mode

  • Compiled React
<Teleport to="#dynamic-container" defer>
  <DynamicContent />
</Teleport>

Enter fullscreen mode Exit fullscreen mode


Compilation strategy summary

VuReact's Teleport compilation strategy demonstrates a complete portal conversion capability:

  1. Direct component mapping: Maps Vue <Teleport> directly to VuReact's <Teleport>
  2. Full attribute support: Supports all attributes including to, disabled, defer, etc.
  3. DOM operation abstraction: Wraps React's Portal functionality to implement teleportation
  4. Error handling: Handles edge cases such as the target container not existing

Core features:

  1. Target specification: Specifies the teleport target via the to attribute (selector or DOM element)
  2. Conditional teleportation: Controls whether teleportation is enabled via disabled
  3. Deferred execution: Delays teleportation timing via defer
  4. Multi-instance support: Supports multiple Teleports pointing to the same target

Important notes:

  1. Target existence: The target container must exist, otherwise it falls back to rendering in place
  2. Dynamic switching: Both disabled and to can be switched dynamically

VuReact's compilation strategy ensures a smooth migration from Vue to React. Developers do not need to manually implement portal logic. The compiled code preserves Vue's teleportation semantics and functionality while following React's component design patterns, keeping the migrated application fully capable of portal-based rendering.

Related Links