rv
react-vue
npm i react-vue
rv

react-vue

Run Vue in React and React Native

by ZC

0.0.5 (see all)License:MITTypeScript:Not Found
npm i react-vue
Readme

react-vue.js

A fork of Vue, only modifies very litter code, extracts its reactivity core, and adds an observer function.

Install

npm install --save react-vue

Usage

import React, { Component } from 'react';
import Vue, { observer } from 'react-vue';

const store = new Vue({
  data () {
    return {
      count: 0
    }
  },
  methods: {
    increase () {
      this.count ++;
    }
  }
});

@observer
export default class Demo extends Component {
  render () {
    return <h1 onClick={store.increase}>{store.count}</h1>;
  }
}

As shown above, the data changes, the view updates. Most of your vue magic is still available in react, even if Vuex.

demo

API

Almost all api points to the vue's official document. If you are familiar with vue, there is no unknown usage.

Global

Options

Instance

observer

Inspiration from mobx, used to convert React components into reactive components.

@observer (decorator) is optional, observer(class Timer ... { }) achieves exactly the same.

Single File Components

Since react-vue only contains vue's reactivity system, there is no lifecycle, no template. For the full support of SFC, try react-vue-loader.

document

License

MIT

No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate