0
0
Vueframework~20 mins

Render function syntax in Vue - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Render Function Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What does this Vue render function output?
Consider this Vue 3 render function using h from vue. What will it render in the browser?
Vue
import { h } from 'vue';

export default {
  render() {
    return h('div', { class: 'container' }, [
      h('h1', 'Hello World'),
      h('p', 'This is a render function example.')
    ]);
  }
}
A<div class="container"><h1>Hello World</h1><p>This is a render function example.</p></div>
B<section class="container"><h1>Hello World</h1><p>This is a render function example.</p></section>
C<div class="container"><h1></h1><p></p></div>
D<div><h1>Hello World</h1><p>This is a render function example.</p></div>
Attempts:
2 left
💡 Hint
Look at the tag names and class attributes used in the render function.
📝 Syntax
intermediate
2:00remaining
Which render function syntax is correct for a Vue 3 functional component?
Select the correct render function syntax for a Vue 3 functional component that renders a
A
export default {
  render() {
    return h('button', 'Click me');
  }
}
B
export default {
  setup() {
    return () =&gt; h('button', 'Click me');
  }
}
C
export default function render() {
  return h('button', 'Click me');
}
D
export default {
  functional: true,
  render() {
    return h('button', 'Click me');
  }
}
Attempts:
2 left
💡 Hint
Vue 3 functional components use setup returning a render function.
🔧 Debug
advanced
2:00remaining
What error does this Vue render function produce?
Identify the error when running this Vue 3 render function code:
Vue
import { h } from 'vue';

export default {
  render() {
    return h('div', { className: 'box' }, 'Content');
  }
}
ANo error, renders a div with class 'box' and text 'Content'.
BTypeError: Cannot read property 'className' of undefined.
CThe class attribute is ignored; the div has no class.
DWarning: Unknown property 'className' used in render function.
Attempts:
2 left
💡 Hint
Vue uses 'class' attribute, not 'className' like React.
state_output
advanced
2:00remaining
What is the output after clicking the button in this Vue render function component?
Given this Vue 3 component with a render function and state, what text will the button show after one click?
Vue
import { h, ref } from 'vue';

export default {
  setup() {
    const count = ref(0);
    function increment() {
      count.value++;
    }
    return () => h('button', { onClick: increment }, `Count: ${count.value}`);
  }
}
ACount: 1
BCount: 0
CCount: NaN
DCount: undefined
Attempts:
2 left
💡 Hint
Reactive refs accessed inside render functions create dependencies that trigger re-renders.
🧠 Conceptual
expert
2:00remaining
Which statement about Vue 3 render functions is true?
Choose the correct statement about Vue 3 render functions and their usage.
ARender functions must always use JSX syntax to work in Vue 3.
BRender functions can only return a single root element; multiple siblings cause errors.
CRender functions can return arrays of elements without wrapping them in a parent element.
DRender functions cannot access reactive state inside setup().
Attempts:
2 left
💡 Hint
Think about how Vue 3 handles fragments in render functions.