Skip to content

Working with Vue 2.7.x Composition API #4930

Discussion options

You must be logged in to vote

Just wanted to loop back here and share what I got working.

// Such a silly hack to not get a new element
const createTextVNode = (text: string) => h('span', text).children?.[0];

/**
 * Vue 2 Compatible version of `FlexRender`
 *
 * Props:
 * - `render` {any} - A function, component, string or number
 * - `props` {object} - Props to pass to the render function or component
 */
export const FlexRender = defineComponent({
  name: 'FlexRender',
  // eslint-disable-next-line vue/require-prop-types
  props: ['render', 'props'],
  setup: props => () => {
    if (typeof props.render === 'function') {
      const rendered = props.render(props.props);

      // If it is a VNODE we have to wrap it…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@dombavetta
Comment options

@pathai-scasarotto
Comment options

Comment options

You must be logged in to vote
1 reply
@dombavetta
Comment options

Answer selected by dombavetta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants