Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

fix class style attrs and children bugs for vue-in-react #118

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/wrappers/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const makeReactContainer = Component => {
export default {
props: ['component', 'passedProps'],
render (createElement) {
return createElement('div', { ref: 'react' })
return createElement('div')
},
methods: {
mountReactComponent (component) {
Expand All @@ -60,15 +60,15 @@ export default {
{...children}
ref={ref => (this.reactComponentRef = ref)}
/>,
this.$refs.react
)
this.$el
);
},
},
mounted () {
this.mountReactComponent(this.$props.component)
},
beforeDestroy () {
ReactDOM.unmountComponentAtNode(this.$refs.react)
ReactDOM.unmountComponentAtNode(this.$el)
},
updated () {
/**
Expand Down
9 changes: 6 additions & 3 deletions src/wrappers/Vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const VUE_COMPONENT_NAME = 'vuera-internal-component-name'
const wrapReactChildren = (createElement, children) =>
createElement('vuera-internal-react-wrapper', {
props: {
component: () => <div>{children}</div>,
component: () => <React.Fragment>{children}</React.Fragment>,
},
})

Expand Down Expand Up @@ -61,20 +61,23 @@ export default class VueContainer extends React.Component {
*/
createVueInstance (targetElement, reactThisBinding) {
const { component, on, ...props } = reactThisBinding.props

// `this` refers to Vue instance in the constructor
reactThisBinding.vueInstance = new Vue({
el: targetElement,
data: props,
...config.vueInstanceOptions,
render (createElement) {
const { className, style, children, ...attrs } = this.$data;
return createElement(
VUE_COMPONENT_NAME,
{
props: this.$data,
on,
class: className,
style,
attrs
},
[wrapReactChildren(createElement, this.children)]
[wrapReactChildren(createElement, children)]
)
},
components: {
Expand Down