Skip to content

allow for jsx/createElement inside template prop functions #7439

Closed
@darrenjennings

Description

@darrenjennings

What problem does this feature solve?

Allows for inlining render functions inside a template for quick expressive rendering. When using render functions to pass into a component, you have to define a method on the vue instance which returns jsx, but would be nice if for small functions you could define them inline and anonymous.

What does the proposed API look like?

allow for JSX inside :

<template>
  <div>
    <my-cool-component :render="() => { return <h1>I will get called inside the cool component!</h1> }"/>
  </div>
</template>
const MyCoolComponent = {
  props: {
    render: {
      type: Function
  },
  render(){
    return (
      <div>{this.$props.render()}</div>
    )
  }
}

If this is a feature that would be accepted, I would be interested in looking into contributing if you could point me in the right direction. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions