3 ms·
svelte’s 2 way data binding is only within a component, and actually is 1 way if you look at the compiled output. very different than say angular, and pretty mu
by swyx 4y ago
svelte’s 2 way data binding is only within a component, and actually is 1 way if you look at the compiled output. very different than say angular, and pretty much equivalent to what you manually write with setState calls.
this is such a common misconception i feel like we should put this in the FAQ somewhere. people are fixating on the wrong thing when they go “oh ho 2 way binding bad”. its local and its compiled away, its fine.
- shirogane86x 4y agoThank you very much for the explanation! I agree with you that this information should be somewhere, especially seeing as I (mistakenly) thought that too, I probably would've had less of a knee-jerk reaction to it if I knew that it's effectively syntax sugar. I'm guessing I'm not the only one who has really bad memories of angular... Sorry for the misunderstanding!
- swyx 4y agoyeah no worries it’s a very common superficial reaction! we just spend a lot of time explaining it: https://twitter.com/rich_harris/status/1420214295242199041?s=21&t=oT1R6bfLJpHjRu7ugYaMEw https://twitter.com/rich_harris/status/1420214295242199041?s... https://twitter.com/rich_harris/status/1147902393293688834?s=21&t=oT1R6bfLJpHjRu7ugYaMEw https://twitter.com/rich_harris/status/1147902393293688834?s... https://www.swyx.io/svelte-why#two-way-binding https://www.swyx.io/svelte-why#two-way-binding