Skip to content
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

Context vs state #21

Open
achou11 opened this issue Mar 2, 2023 · 1 comment
Open

Context vs state #21

achou11 opened this issue Mar 2, 2023 · 1 comment

Comments

@achou11
Copy link

achou11 commented Mar 2, 2023

Hello! First, just want to say how awesome this project is :) Reminds me a lot of Choo (which I love and you acknowledge for the router) but with some more opinionated structure 😄

Reading through the docs and there are hints about when to represent something as context vs state, but nothing fully documented. As someone who doesn't have a ton of experience using FSMs in UI, I was hoping you - or anyone who comes across this - could elaborate when to use which, perhaps in the context of some common UI patterns.

Looking forward to trying Baahu out at some point, thanks!

@achou11
Copy link
Author

achou11 commented Mar 2, 2023

rereading the docs and I think it's become clearer to me actually. from what I gather, state is referring to the machine state rather than component state. context seems more appropriate for component state i.e. data that you use when rendering. would it be fair to say the following?

  • machine state changes as a result of events that are emitted

  • component state (i.e. context) changes as a result of side-effects caused by machine state changes or relevant events being emitted

if this seems more-or-less accurate, feel free to close this. appreciate any additional clarifications though 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant