DEV Community

Cover image for React, Vue and Svelte: Comparing how to get Props
Clément Creusat
Clément Creusat

Posted on

React, Vue and Svelte: Comparing how to get Props

Getting props in...

Svelte syntax for getting prop can be kinda confusive. Svelte uses the export term but we are importing some prop...
Vue has his own object method defineProps and React read them through the props object.

Check it out 🚀

React

Link

const Component = (props) => {
  return props.msg
}
Enter fullscreen mode Exit fullscreen mode

Vue

Link

const props = defineProps({
  msg: String
})
<template>{{ msg }}</template>
Enter fullscreen mode Exit fullscreen mode

Svelte

Link

<script>
  export let msg = '';
<script>

{msg}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)