[Vuejs]-Vue render function causes maximum call stack

0👍

Here is how to achieve a render function in Vue:

App.vue

<script setup>
import Comp from './Comp.vue'
</script>

<template>
  <comp>
    cool slot
  </comp>
</template>

Comp.vue

<script>
import { h } from 'vue'

export default {
  setup(props, { slots }) { 
    return () => h('form', slots.default())
  }
}
</script>

Here is the doc if you want more details (+ the approach for JSX).

Leave a comment