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

推荐订阅源

L
LangChain Blog
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
Vercel News
Vercel News
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
云风的 BLOG
云风的 BLOG

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
What Does Vue 3 reactive() Compile to in React with VuReact?
Ryan John · 2026-05-20 · via DEV Community

Ryan John

VuReact compiles Vue 3 code into standard, maintainable React code. This time, the focus is on two of Vue's most common reactive APIs: reactive() and shallowReactive().

If you write them in Vue, what does the resulting React code actually look like?

Before the Examples

To keep the article focused, these examples follow two small conventions:

  1. All Vue and React snippets show only the core logic, with component wrappers and unrelated setup omitted.
  2. The article assumes you are already familiar with the API shape and core behavior of Vue 3 reactive and shallowReactive.

Compilation Mapping

Vue reactive() -> React useReactive()

reactive() is one of the most common entry points into Vue 3 reactivity. It wraps objects and arrays in a reactive proxy so property changes can drive view updates.

Here is the most basic example:

  • Vue
<script setup>
import { reactive } from 'vue';

const state = reactive({
  count: 0,
  title: 'VuReact',
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

// Compiled into a Hook that mirrors Vue reactive behavior
const state = useReactive({
  count: 0,
  title: 'VuReact',
});

Enter fullscreen mode Exit fullscreen mode

This is the core mapping: Vue reactive() becomes the React Hook useReactive().

VuReact's useReactive is the runtime adapter for reactive. You can think of it as the React-side equivalent of Vue's object reactivity model, preserving familiar behavior such as reactive property updates, direct nested property access, and smooth integration with React component rendering.

TypeScript Types Are Preserved

VuReact also keeps type information intact, which matters a lot in real-world TypeScript codebases.

  • Vue
<script lang="ts" setup>
import { reactive } from 'vue';

interface User {
  id: number;
  name: string;
}

const state = reactive<{
  loading: boolean;
  users: User[];
  config: Record<string, any>;
}>({
  loading: false,
  users: [],
  config: { theme: 'dark' },
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

interface User {
  id: number;
  name: string;
}

const state = useReactive<{
  loading: boolean;
  users: User[];
  config: Record<string, any>;
}>({
  loading: false,
  users: [],
  config: { theme: 'dark' },
});

Enter fullscreen mode Exit fullscreen mode

There is no need to rework the types by hand. VuReact carries the original annotations forward so the generated React code keeps the same type safety and editor experience.

Vue shallowReactive() -> React useShallowReactive()

shallowReactive() creates a shallow reactive object in Vue 3. It is useful when you only want to observe changes at the top level, rather than deeply tracking every nested property.

  • Vue
<script setup>
import { shallowReactive } from 'vue';

const state = shallowReactive({
  nested: { count: 0 },
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

const state = useShallowReactive({
  nested: { count: 0 },
});

Enter fullscreen mode Exit fullscreen mode

This follows the same idea as reactive(): Vue shallowReactive() is compiled into useShallowReactive().

VuReact's useShallowReactive is the runtime adapter for shallowReactive. In other words, only top-level reference changes are tracked, while nested mutations do not trigger updates. That makes it a practical fit for large objects, third-party data, or performance-sensitive structures where deep tracking would be unnecessary.