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

推荐订阅源

B
Blog RSS Feed
Martin Fowler
Martin Fowler
爱范儿
爱范儿
IT之家
IT之家
Last Week in AI
Last Week in AI
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
The Cloudflare Blog
MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
腾讯CDC
Microsoft Security Blog
Microsoft Security 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
How does VuReact compile Vue 3's lifecycle hooks to React?
Ryan John · 2026-05-22 · via DEV Community

Ryan John

VuReact is a tool that compiles Vue 3 code into standard, maintainable React code. In this article, we will look at how common Vue 3 lifecycle hooks are mapped into React.

If you write Vue lifecycle hooks, what does VuReact generate on the React side?

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 lifecycle hooks such as onMounted, onBeforeMount, onBeforeUpdate, onUpdated, onBeforeUnmount, and onUnmounted.

Compilation Mapping

Vue onMounted() -> React useMounted()

onMounted() is Vue 3's hook for running logic after a component is mounted for the first time. It is commonly used for initialization requests, subscriptions, and DOM-related setup.

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

onMounted(() => {
  console.log('component mounted');
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

useMounted(() => {
  console.log('component mounted');
});

Enter fullscreen mode Exit fullscreen mode

VuReact's useMounted is the runtime adapter for onMounted(), preserving the same post-mount execution timing.

Vue onBeforeMount() -> React useBeforeMount()

onBeforeMount() is Vue 3's hook for logic that should run right before the first mount.

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

onBeforeMount(() => {
  console.log('component is about to mount');
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

useBeforeMount(() => {
  console.log('component is about to mount');
});

Enter fullscreen mode Exit fullscreen mode

VuReact's useBeforeMount is the runtime adapter for onBeforeMount(), preserving the same pre-mount timing.

Vue onBeforeUpdate() -> React useBeforeUpdate()

onBeforeUpdate() runs before a component update, excluding the initial mount. It is useful when you need to inspect or prepare state before the next render is committed.

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

const state = reactive({ count: 0 });

onBeforeUpdate(() => {
  console.log('before update, count:', state.count);
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

const state = useReactive({ count: 0 });

useBeforeUpdate(
  () => {
    console.log('before update, count:', state.count);
  },
  [state.count],
);

Enter fullscreen mode Exit fullscreen mode

VuReact's useBeforeUpdate is the runtime adapter for onBeforeUpdate(). When the React-side API needs dependencies, VuReact analyzes them during compilation and generates the dependency array automatically.

Vue onUpdated() -> React useUpdated()

onUpdated() runs after a component update. It is commonly used to read the latest rendered result or trigger follow-up synchronization work.

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

const state = reactive({ count: 0 });

onUpdated(() => {
  console.log('after update, count:', state.count);
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

const state = useReactive({ count: 0 });

useUpdated(
  () => {
    console.log('after update, count:', state.count);
  },
  [state.count],
);

Enter fullscreen mode Exit fullscreen mode

VuReact's useUpdated is the runtime adapter for onUpdated(), with dependency analysis handled automatically during compilation when needed.

Vue onBeforeUnmount() -> React useBeforeUnMount()

onBeforeUnmount() is Vue 3's hook for logic that should run right before a component is removed.

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

onBeforeUnmount(() => {
  console.log('component is about to unmount');
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

useBeforeUnMount(() => {
  console.log('component is about to unmount');
});

Enter fullscreen mode Exit fullscreen mode

VuReact's useBeforeUnMount is the runtime adapter for onBeforeUnmount(), preserving the expected pre-unmount timing.

Vue onUnmounted() -> React useUnmounted()

onUnmounted() is Vue 3's hook for final cleanup after a component has been removed.

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

onUnmounted(() => {
  console.log('component unmounted');
});
</script>

Enter fullscreen mode Exit fullscreen mode

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

useUnmounted(() => {
  console.log('component unmounted');
});

Enter fullscreen mode Exit fullscreen mode

VuReact's useUnmounted is the runtime adapter for onUnmounted(), preserving the expected unmount timing.

Related Links