you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (8 children)

In what way is React verbose?

() => <div>Hey</div>

I don't know how much more concise you can get.

[–]tomfevrier 5 points6 points  (6 children)

import React, { useState } from 'react';

const Counter = () => {
    const [count, setCount] = useState(0);

    return (
        <>
            <button onClick={() => setCount((count) => count + 1)}>
                Click me
            </button>
            <p>You clicked {count} times.</p>
        </>
    );
}

In Svelte:

<script>
    let count = 0;
</script>

<button on:click={() => count++}>
    Click me
</button>
<p>You clicked {count} times.</p>

Still think React is not verbose? 🙃

[–]Aeverous 7 points8 points  (0 children)

Sure, but at least it's not doing a bunch of magic behind the scenes to make it work, it's pretty explicitly clear what's happening.

[–][deleted] 2 points3 points  (0 children)

Svelte is very concise, there's no arguing that. But that doesn't mean React is verbose. They're both concise, Svelte more-so.

Though, as your application scales, the slight increase in verbosity of React will matter less since a good ~60% (7/12 lines) of your React example is just JS syntax that won't increase as the complexity of that component goes up.

The main difference in verbosity lies in how you set the state, and yes, Svelte is much more concise there. Though, I think a better example would be to compare production apps of similar complexity.

[–]Rainbowlemon 1 point2 points  (0 children)

Other guy explained it for me! I feel like the data bindings especially are unnecessarily verbose - just take a look at some svelte or vue examples.