Hey guys, so i am new to cljs and i am experimenting with it, and like every noob, I have an issue, i have a form, and whenever i submit the form, with a on-click event, sometimes it refreshes the screen losing the state (i am using reframe) and sometimes it doesnโt, but the behaviour is never the expected one on the firt try. I know this might be something simple, but have you guys any idea on what can be going on?
The default action of a <form> element when some <button> within it is pressed that has the default type or type="submit" is to, well, submit itself - it will cause a page refresh, or a navigation to a different page if the web server responds in a specific way.
Sounds like you need :on-submit #(.preventDefault %) in [:form {...}]. Maybe something else should be going on in that handler, e.g. maybe it's :on-submit that should be issuing some relevant re-frame event and not that button since a form can be submitted without any buttons.
Ok, i Will try that and let you know if it works out
Thanks!
btw, on another question, do you know if we can get rid of this warning in console? Warning: findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference
the browser console does allow you to filter by log severity
That message is probably originating in a JS library you are using and I don't know of a way to disable it
except to toggle warnings in the console
yes, but is this one of those warnings that we can get rid of without filtering? I mean make it adhere to the priciples that avoid this log? or is this something that will go away with a prod build?
What exactly issues that warning?
When I open the application it just shows that warning, and it seems to point to react itself, so I would say maybe reagent does it?
Click on that triangle to the left of the warning to see the stacktrace.
re-frame-10x
that must be it
Indeed. You're using an older version of re-frame-10x and/or it's misconfigured. See the first text after the table at https://github.com/day8/re-frame-10x?tab=readme-ov-file#compatibility-matrix.
i switched to 1.10.1
but i still get the same warning
there's people there complaining about it
Did you configure it properly, like that text said that I linked to?
yes
now it says this
I did what that says, will try now
Make sure to fully restart shadow-cljs, just in case. (Some people use separate server and worker processes - everything should be restarted.)
If that doesn't work, try removing .shadow-cljs dir from the project.
ok
ok, warnings are now gone
thanks for all your help guys, much appreciated!