A fork of Vue, only modifies very litter code, extracts its reactivity core, and adds an observer function.
npm install --save react-vue
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.
Almost all api points to the vue's official document. If you are familiar with vue, there is no unknown usage.
observer
Inspiration from mobx, used to convert React components into reactive components.
@observer
(decorator) is optional, observer(class Timer ... { })
achieves exactly the same.
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.
Version | Tag | Published |
---|---|---|
0.0.5 | latest | 6yrs ago |