React, Vue and Svelte: Comparing Text Input Binding

Text Input Binding in…

Text input binding is the simplest thing in form binding. React asks us to write more code to handle this. In the opposite, Vue and Svelte do some magic for us!

Check it out 🚀

React

Live Example

const…


This content originally appeared on DEV Community and was authored by Clément Creusat

Text Input Binding in...

Text input binding is the simplest thing in form binding. React asks us to write more code to handle this. In the opposite, Vue and Svelte do some magic for us!

Check it out 🚀

React

Live Example

const [text, setText] = useState<string>('Hello');

const handleChange = ({
   target: { value },
}: React.ChangeEvent<HTMLInputElement>) => {
  setText(value);
};

<section>
  <h2>Text Input</h2>
  <input value={text} onChange={handleChange} />
  <p>{text}</p>
</section>

Vue

Live Example

const text: Ref<string> = ref('Hello');

<section>
  <h2>Text Input</h2>
  <input v-model="text" />
  <p>{{ text }}</p>
</section>

Svelte

Live Example

let name: string = 'Hello';

<section>
  <h2>Text Input</h2>
  <input bind:value={name} />
  <p>{name}</p>
</section>


This content originally appeared on DEV Community and was authored by Clément Creusat


Print Share Comment Cite Upload Translate Updates
APA

Clément Creusat | Sciencx (2022-04-05T18:16:03+00:00) React, Vue and Svelte: Comparing Text Input Binding. Retrieved from https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/

MLA
" » React, Vue and Svelte: Comparing Text Input Binding." ClĂ©ment Creusat | Sciencx - Tuesday April 5, 2022, https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/
HARVARD
ClĂ©ment Creusat | Sciencx Tuesday April 5, 2022 » React, Vue and Svelte: Comparing Text Input Binding., viewed ,<https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/>
VANCOUVER
ClĂ©ment Creusat | Sciencx - » React, Vue and Svelte: Comparing Text Input Binding. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/
CHICAGO
" » React, Vue and Svelte: Comparing Text Input Binding." ClĂ©ment Creusat | Sciencx - Accessed . https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/
IEEE
" » React, Vue and Svelte: Comparing Text Input Binding." ClĂ©ment Creusat | Sciencx [Online]. Available: https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/. [Accessed: ]
rf:citation
» React, Vue and Svelte: Comparing Text Input Binding | ClĂ©ment Creusat | Sciencx | https://www.scien.cx/2022/04/05/react-vue-and-svelte-comparing-text-input-binding/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.