DEV Community

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

Posted on • Edited on

4 2

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

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)