Skip to content
Discussion options

You must be logged in to vote

I would probably do it with a computed of the filtered list, and pass that into For. But your approach should work just fine - if you change language.peek() to language.get() it'll be reactive. If you want to overoptimize it (which probably isn't necessary) you you could move r.language.get() out to local state.

Benefits of each approach:

  • For: Creating a computed in React creates a useRef, a useMemo, and a computed, which adds a very tiny overhead. But then when the list changes the renders will be constrained to inside For, so it saves full component renders. So it's mainly better if the component is heavy. Or if there's a lot of list elements that re-sort often, optimized mode is a goo…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
4 replies
@djMax
Comment options

@jmeistrich
Comment options

@djMax
Comment options

@jmeistrich
Comment options

Answer selected by djMax
Comment options

You must be logged in to vote
4 replies
@jmeistrich
Comment options

@djMax
Comment options

@jmeistrich
Comment options

@djMax
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants