babel-plugin-jsx-vue-functional icon indicating copy to clipboard operation
babel-plugin-jsx-vue-functional copied to clipboard

Allow to pass props as first argument

Open wonderful-panda opened this issue 6 years ago • 0 comments

TypeScript supposes first argument of functional component is props.

https://www.typescriptlang.org/docs/handbook/jsx.html#stateless-functional-component

It would be nice if some option will be added that treats first argument as props.

Example:

const A = (props: { msg: string }, { listeners }) => <div onClick={listeners.click}>{props.msg}</div>;

will be transpiled into

const A = {
  functional: true,
  render: (h, ctx) => (
    (props, { listeners }) => <div onClick={listeners.click}>{props.msg}</div>
  )(ctx.props, ctx)
}

wonderful-panda avatar Jul 04 '18 04:07 wonderful-panda