Reactivity in on:submit is not working as expected
See original GitHub issueDescribe the bug I am not seeing my error message when I click the button with an empty input field.
To Reproduce First REPL where you see the expected behavior: https://svelte.dev/repl/27fea1d7bd10434eacc89606ad15ff8c?version=3.12.1 Load the page, hit the button, see the error message
Second REPL that shows how I actually want my code to be: https://svelte.dev/repl/de196c90bd834266bf78d7f686eb0802?version=3.12.1 Load the page, hit the button, no error message. Type in the input, the error message shows up
Expected behavior
The second REPL should work. Alternatively, if I could somehow bind the this
for the on:submit
function would that make this problem go away (e.g. is the static fn callstack somehow causing this problem)?
What do I need to change, or is there a bug, why my second example doesn’t work?
Severity This is a considerable issue in writing re-usable JS in projects.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
OK, I was able to make it work with
set/getContext
—> https://svelte.dev/repl/aec39420455e495cbf1c27471885e364?version=3.12.1However, if I may be so bold, I noticed I cannot bind to a variable declared with the let:directive. I can understand why that would be a giant mess. However, it means I would have to create components for each tag I want to bind a value to. It means a lot of boilerplate, which is something I can live with — but I am wondering what the easiest way to allow all the html attributes (type, class, style, data-…) through the component props without having to type them all out (which, with data attrs could literally be endless)?
How “bad” would it be to use
$$props
within<Input>
to grab everything? (Imagine there are a lot of<Input>'s
)