Vue · Senior · Question 49 of 75
When would you write a render function with h()?
const Heading = (props, { slots }) => h(`h${props.level}`, slots.default?.());- ✓Correct answer: When the output structure is highly dynamic, e.g. choosing the tag at runtime or building library primitives
- 2For every component, because templates are deprecated
- 3Only for server rendering
Explanation
Functional components like this have no state or instance. For most UI, templates are clearer and better optimized.