-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversion between JS and clj doesn't preserve key order, messing up this.props.children #6
Comments
It seems like we're running into an implementation detail of Mori here. These two are not equivalent: console.log(
toObj(nextProps.children),
M.clj_to_js(M.js_to_clj(toObj(nextProps.children)))
); When converting object back and forth, key order may change—and we currently rely on key order when rebuilding This is also visible in third example if you start with too many items: |
I got a PR for this (#7), basically the fix is to store key-value pairs explicitly so order doesn't get lost. |
Man you're fast lol. Yeah I knew this was the case. I just didn't think someone would play around with this lib so quickly. I actually had some local code to fix this behaviour but it was relatively low-pri. I'll do it when I find the time (slightly busy here) |
Yeah sure. I just got super excited about this lib and couldn't wait :-) |
I can't figure out why this happens.
I copy-pasted third example, but I wanted to play with text inputs. For starters, I tried simplest example possible: I wanted to animate
, world
away and back inside a<div>
.This is what I did:
However, this refused to work with
Container
: items would animate but children order would get messed up when I click.I soon realized that this line messes up child order:
(namely, I had to remove
toObj
call)Similarly, I had to change the loop in
Container#render
to enumerate an array instead:Why does this happen when going over characters? It's not like this is too different from your App3 example.
You can play with it in this branch.
The text was updated successfully, but these errors were encountered: