DEV Community

Cover image for React, Vue and Svelte: Comparing Children Component
Clément Creusat
Clément Creusat

Posted on • Edited on

React, Vue and Svelte: Comparing Children Component

Children in...

React

Link

// Parent Component
<User>
  Front-end Developer
</User>

// Child Component
const User = (props) => {
  return <p>{props.children}</p>
}
Enter fullscreen mode Exit fullscreen mode

Vue

Link

// Parent Component
<User>
  Front-end Developer
</User>

// Child Component
<template>
  <slot>Display if no children passed</slot>
</template>
Enter fullscreen mode Exit fullscreen mode

Svelte

Link

// Parent Component
<User>
  Front-end Developer
</User>

// Child Component
<div>
  <slot>Display if no children passed</slot>
</div>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)