babel-plugin-transform-react-to-vue icon indicating copy to clipboard operation
babel-plugin-transform-react-to-vue copied to clipboard

Detect render props smartly

Open andreiglingeanu opened this issue 6 years ago • 0 comments

Hello, first of all thanks for such an awesome transformer!

Currently a component which looks like that gets transpiled into a naive this.$attrs.renderProp(this.$data) call, which of course is not correct. The best way would be to take advantage of scoped slots.

import React from 'react'

class Mouse extends React.Component {
  render() {
    return (
      <div>
        {this.props.renderProp(this.state)}
      </div>
    )
  }
}

A description of render props in React can be found here and a real world usage of scoped lots in Vue can be found here.

Thanks for considering that!

andreiglingeanu avatar Nov 23 '17 22:11 andreiglingeanu