File tree 4 files changed +96
-0
lines changed
4 files changed +96
-0
lines changed Original file line number Diff line number Diff line change 1
1
# reactify-vue
2
+
2
3
transforms a vue component in a react one
4
+
5
+ ## usage example
6
+
7
+ * export a vue component as a react builder:
8
+
9
+ ` ReactPayment.js `
10
+ ```
11
+ import Vue from 'vue'
12
+ import PaymentApp from './PaymentApp.vue'
13
+ import reactify from 'reactify-vue'
14
+
15
+ export default reactify(Vue, PaymentApp)
16
+ ```
17
+
18
+ * Import the react builder and use it as a react component
19
+
20
+ ` ConsumerComponent.js `
21
+
22
+ ```
23
+ import React from 'react'
24
+ import paymentBuilder from 'payment'
25
+ import 'payment/lib/payment.css'
26
+ const ReactPayment = paymentBuilder(React)
27
+
28
+ [...]
29
+
30
+ render () {
31
+ return (
32
+ <Layout>
33
+ <div>TEST</div>
34
+ <ReactPayment prop1="value prop 1" $trigger={this.handleEvt}></ReactPayment>
35
+ </Layout>
36
+ )
37
+
38
+ [...]
39
+
40
+ ```
41
+
42
+ ## TODO
43
+
44
+ * compute a unique hash for multiple reactified components and use it as element id
45
+ * tests
Original file line number Diff line number Diff line change
1
+
2
+ // compute a unique hash for multiple reactified components
3
+ const getId = component => {
4
+ return 'vue-component-id'
5
+ }
6
+
7
+ export default ( _vueInstance , component ) => _reactInstance => {
8
+ const id = getId ( component )
9
+
10
+ return class Wrapper extends _reactInstance . Component {
11
+ render ( ) {
12
+ return _reactInstance . createElement ( 'div' , { id } )
13
+ }
14
+ componentDidMount ( ) {
15
+ new _vueInstance ( {
16
+ el : `#${ id } ` ,
17
+ components : { app : component } ,
18
+ render : createElement => createElement ( 'app' , { props : this . props } )
19
+ } )
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " reactify-vue" ,
3
+ "version" : " 0.1.0" ,
4
+ "description" : " reactify vue components" ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 1"
8
+ },
9
+ "repository" : {
10
+ "type" : " git" ,
11
+ "url" : " git+https://github.com/musement/reactify-vue.git"
12
+ },
13
+ "keywords" : [
14
+ " reactify" ,
15
+ " react" ,
16
+ " vue" ,
17
+ " component" ,
18
+ " components"
19
+ ],
20
+ "author" : " lsimone" ,
21
+ "license" : " MIT" ,
22
+ "bugs" : {
23
+ "url" : " https://github.com/musement/reactify-vue/issues"
24
+ },
25
+ "homepage" : " https://github.com/musement/reactify-vue#readme"
26
+ }
You can’t perform that action at this time.
0 commit comments