Vuact is a React runtime compatibility layer for Vue 3. It enables seamless usage of the React component ecosystem inside Vue 3 projects, with two-way interoperability between Vue and React for components, events, reactivity, Context, Ref, and more.
Key value:
For the full configuration and initialization flow, see setup-config.md.
Vuact provides two core functions to convert components between Vue and React:
Examples:
Vuact provides a flexible slots and render-props transformation mechanism:
slot:Vuact automatically transforms props and events between Vue and React:
class → React classNamestyle (string or object) → React style (object)className → Vue classstyle (object; auto-add px for unitless values) → Vue stylev-model update events → React onUpdate:xxxExamples:
Vuact supports two-way Context passing between Vue and React:
provideContextVueContextProviderExamples:
Vuact supports passing refs between Vue and React components:
ref to get a React component instanceref to get a Vue component instanceuseImperativeHandleExamples:
Vuact lets you use Vue reactivity directly inside React components:
useVueEffectScoperef, watch, computed, etc. within that scopeExamples:
Because Vuact is essentially based on Vue, some behaviors cannot fully match React:
useInsertionEffect timing differs from ReactgetSnapshotBeforeUpdate timing differs from React@vue/runtime-dom cannot fully match react-domreact-dom's SyntheticEvent differs from standard web eventsreact-dom applies special handling for some native DOM elements (e.g. input, form, etc.)Load the relevant reference docs to get complete example code and detailed explanations.
共 1 个版本