Skip to content

Commit 85099b2

Browse files
author
loris
committed
enhanced builder function
1 parent 360303c commit 85099b2

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
transforms a vue component in a react one
44

5+
TODO: to be updated after latest modifications
6+
57
## usage example
68

79
* export a vue component as a react builder:

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'reactify-vue';

index.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
2-
// compute a unique hash for multiple reactified components
1+
// TODO: compute a unique hash for multiple reactified components
32
const getId = component => {
4-
return 'vue-component-id'
5-
}
3+
return "vue-component-id";
4+
};
65

7-
export default (_vueInstance, component) => _reactInstance => {
8-
const id = getId(component)
6+
export default buildVueInstance => _reactInstance => {
7+
const id = getId();
98

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-
}
9+
return class Wrapper extends _reactInstance.Component {
10+
render() {
11+
return _reactInstance.createElement("div", { id });
12+
}
13+
componentDidMount() {
14+
const vueApp = buildVueInstance(this.props)
15+
vueApp.$mount(`#${id}`);
2116
}
22-
}
17+
};
18+
};

0 commit comments

Comments
 (0)