Fork me on GitHub
#reagent
<
2024-04-18
>
itaied07:04:34

how do reagent handles order of keys for style when cljs map with over 8 keys doesn't preserve order? I'm facing an issue (using react directly) with a style map with more than 8 keys, where 2 keys order is important

juhoteperi08:04:56

It doesn't. Probably the map value is used as is for doseq or such so you could be able to build a array-map yourself if you really need. What properties care about the order?

juhoteperi08:04:40

Or if it doesn't work with React directly, it could be React itself will not care about style property order and it wouldn't help at all if Reagent keeps the order from Cljs array-map -> JS object

itaied08:04:22

i had an issue with background-clip coming before background

itaied08:04:34

ended up changing background to background-image

Roman Liutikov09:04:02

this sounds interesting, style props order should not matter within the same block of styles

john11:04:39

Do JavaScript object/maps preserve insertion order?

itaied11:04:17

not guaranteed, but 99% of the use cases they do

juhoteperi13:04:14

If I recall Reagent convert-props code, it should also use JS values as-is, so you could write :style #js {...} and it should use the value for the React element without conversion. But probably better idea in these cases to use the more specific CSS properties, instead shorthand properties and then specific properties to override something from the shorthand.

juhoteperi13:04:06

Not sure how clear even the CSS spec is about order the properties are read in