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

Stateful vs. Stateless components #31

Closed
XVincentX opened this issue Sep 9, 2015 · 3 comments
Closed

Stateful vs. Stateless components #31

XVincentX opened this issue Sep 9, 2015 · 3 comments

Comments

@XVincentX
Copy link
Contributor

No description provided.

@Baggz Baggz changed the title Stateful vs Stateless components Stateful vs. Stateless components Sep 9, 2015
@Baggz
Copy link
Contributor

Baggz commented Sep 9, 2015

Ah, true, @XVincentX, good point!

@XVincentX
Copy link
Contributor Author

So, I am not expert yet in the React, but I will, anyway, kickoff the discussion.

Since state increases complexity and reduces predictability, a Component without state is preferable. Even though you clearly can't do without state in an interactive app, you should avoid having too many Stateful Components.

But of course, we cannot create applications without states, so they must live somewhere.

I think a good way to identify a component that should have a state is when it is the only one listening to an event.

I'll make an example from the current code.

As you can see, Playground and RefractPreview are listening to the same event.

In this case, I would just let Playground component listen to the event, and then propagate that to the subcomponents that will re render themselves.

What do you think about?

This commit goes in that direction, by the way.

@Baggz
Copy link
Contributor

Baggz commented Sep 21, 2015

Tracking as https://github.com/apiaryio/kit-template/issues/4 in the kit-template repository.

@Baggz Baggz closed this as completed Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants