DEV Community

Cover image for React, Vue and Svelte: Comparing Dynamic Attributes
Clément Creusat
Clément Creusat

Posted on • Updated on

React, Vue and Svelte: Comparing Dynamic Attributes

Dynamic attributes in...

To declare an attribute, React uses one hook :
useState where you have declare the variable and the set state method.
The syntax of Vue and Svelte is quite similar except Vue uses his ref method to handle reactivity.

To read them, React and Svelte have the same syntax. Vue, in other hand, goes full mustache syntax with 2 curly braces.

Check it out 🚀

React

Link

import { useState } from 'react';

const Component = () => {
  // state
  const [message, setMessage] = useState('Hello');

  return <div>{ message }</div>
}
Enter fullscreen mode Exit fullscreen mode

Vue

Link

<script setup lang="ts">
  import { ref } from 'vue'; 
  // state
  const message = ref('hello');
</script>

<template>
 <div>{{ message }}</div>
</template>
Enter fullscreen mode Exit fullscreen mode

Svelte

Link

<script lang="ts">
// state
let message = '';
<script>

<div>{ message }</div>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)