-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLJS data structures are compared by ref in <-effect deps #39
Comments
Solution is to capture deps in a ref and do the equality check in clojure, pass result to React |
Fixed via ba0d520 |
I was just reading up on this, came to post about it :) Doesn’t useState have the same issue? React will skip the render if the returned value is the same as the previous one, but it uses the same algorithm. |
Ah, I didn’t think to check useState as well. Good call out! I wonder if there is a good way to handle that... I’m not sure how to do the comparison if the value given to the update function is itself a function to be applied, without doing the computation twice. And using a ref we might end up creating similar bugs as with atomified <-state. |
I’ve commented on that react issue as pointed by Roman in Twitter: Some similar efforts to bridge Hooks and ClojureScript are here: |
Hello! Do you have any ideas how this can be fixed for Including @mhuebert in this discussion, since he's working on a wrapper as well. |
I don't have any specific thoughts in mind yet. I am working though on a real-world application that's built entirely on hx, so I'm using that as a real-life place to validate new ideas. The thing that is really great with hooks though is that the API surface is rather small, so it's easy to write different wrappers and see how they behave. Their composability is what makes me want to keep pushing this, since doing the same with class-based components was pretty much impossible. |
Actually I think this is an easy fix for |
Yeah, that's the obvious fix. We discussed at length with @Lokeh whether it makes sense to expose the "ref" semantics of atoms, because they can be confusing if you're expecting normal clojure atom behaviour. See #11 (comment) |
I was trying to think of values for which Clojure would say |
I think that's a very good point and a test suite could be setup to explore this. If it's only |
This can lead to during the effect more often than desired, since it does not use Clojure's equality semantics.
The text was updated successfully, but these errors were encountered: