Skip to content

How to build components with a lot of external properties? #313

Answered by gbj
flosse asked this question in Q&A
Discussion options

You must be logged in to vote

There are a few different questions to ask yourself when you find yourself in this situation:

  1. If it's not local state, does it need its own component? You can keep it in a larger parent component.
  2. Do all these props need to be passed into one component, or can I break this out into several smaller components with fewer props?
  3. Is it cleaner if I pass some of these with provide_context and receive them with use_context instead of via props?
  4. Is it cleaner if I use a struct and a message enum to create a state machine as I would in Elm, and pass that as a signal?

Without a more concrete example it's a bit hard to see what the answer is in your case, but those are some of the possibilities.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@flosse
Comment options

@gbj
Comment options

@flosse
Comment options

Answer selected by flosse
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