This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-12
Channels
- # beginners (63)
- # boot (3)
- # braveandtrue (153)
- # cider (19)
- # cljdoc (2)
- # clojure (80)
- # clojure-dev (25)
- # clojure-italy (73)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (67)
- # clojure-sweden (1)
- # clojure-uk (83)
- # clojurescript (56)
- # clojutre (11)
- # core-logic (37)
- # cursive (18)
- # datomic (14)
- # editors (10)
- # emacs (13)
- # figwheel-main (11)
- # fulcro (62)
- # graphql (11)
- # jobs (3)
- # klipse (1)
- # leiningen (6)
- # off-topic (91)
- # onyx (7)
- # pedestal (3)
- # portkey (5)
- # re-frame (14)
- # reagent (13)
- # remote-jobs (1)
- # shadow-cljs (111)
- # tools-deps (4)
- # yada (10)
@U8ES68TGX Thanks for the response. The first point is good to know - I bet I have done that in my code. I found some other docs on it also, but I don't see it in the main docs yet: https://presumably.de/reagent-mysteries-part-1-vectors-and-sequences.html#gotchas ...
About the keys and lists. I think I understand the need for keys and how they help performance with lists. I guess I am curious if keys are specific to list data structures or if they are also helpful for plain-old children. For example: [:div [:div] [:div]]
vs [:div (list [:div] [:div])]
. When using Clojurescript and into
we can dynamically generate the first div from a list. I see some libraries do this (accept a list and into
the list into a div). Do you know if React will make use of keys anyways in the first example?
@leblowl it is mentioned briefly here (item 4), but admittedly this is kind of out of the way https://github.com/reagent-project/reagent/blob/master/doc/FAQ/ComponentNotRerendering.md
yes, there is a difference between [:div [:div] [:div]]
vs [:div (list [:div] [:div])]
. The latter version passes the sequence to react differently than the first version. React only attempts to do its key-based optimization if you pass using the later convention
there are lots of times when just using into
is fine because you are not going to manipulate a sequence in a way that would allow the key optimization to do anything useful for you. e.g., if you are creating a drop-down menu from a map of keys, the elements in the dropdown are always going to be in the same order, so you really don’t need to invent keys
in terms of the performance impact, using a sequence with keys can potentially help performance if you have meaningful keys and do things like move/insert object in the sequence (and the sequence is long)
often a sequence will never be edited in that way so there’s no performance impact. i.e., the sequence is a menu or something that isn’t really dymanic
Is there a go-to solution for resetting/maintaining scroll position when using an HTML5 History API-based router?
I.e. the equivalent of https://reacttraining.com/react-router/web/guides/scroll-restoration — where navigating to a new “page” should scroll to the top, whereas pressing back should restore the previous position?