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

[State Magement] Include setState + new context API #4

Closed
aoc opened this issue Jun 28, 2018 · 6 comments
Closed

[State Magement] Include setState + new context API #4

aoc opened this issue Jun 28, 2018 · 6 comments

Comments

@aoc
Copy link

aoc commented Jun 28, 2018

I think it's important to fully understand setState and new context API before learning a more complex solution like redux or mobX.
It usually covers most of the state management requirements and let's you understand what problems those tool help you with.

@aoc
Copy link
Author

aoc commented Jun 28, 2018

great work btw! :) I can create a PR if you want

@adam-golab
Copy link
Owner

Thanks for adding this issue with your thoughts :)
Regarding the setState and state management built into React, I think that it's included in the "Learn React" step. It may be a good idea to explicitly emphasize that learning React contains following key features:

  • class Component, stateless, PureComponent
  • state management (setState)
  • lifecycle methods
  • JSX
  • context API
  • and so on (if you have any additional key features, feel free to suggest)
    I think the best place for such information is not on the graphic but in the readme.

Regarding the context API, to be honest I don't agree that is necessary to understand it before learning Redux or Mobx. It's very helpful to know this mechanism, it explains a lot of things that happen "under the hood". But the knowledge that redux's Provider component and connect HOC can pass state through every level of the tree is sufficient at the beginnings.

@aoc
Copy link
Author

aoc commented Jun 28, 2018

I didn't mean that the context API is required to understand redux / mobx, and I agree with you it's not necessary.

Looking at the graphic someone may incorrectly think you require a library to handle state management, specially if you're talking about learning material.

In my opinion you can introduce the concept of state management (local state vs global state, lifting state up, etc) only using React's API. After that you can explain which problems redux and mobx try to solve.

Passing state through different levels of the tree can be explained using the new context API.

@aoc
Copy link
Author

aoc commented Jun 28, 2018

Maybe it's a matter of taste, but I try to avoid introducing libraries, which include more complexity and new problems. Of course there is always a tradeoff, but you need to fully understand the underlying problem (or limitation) the library is trying to solve to decide if it's worth it.

@adam-golab
Copy link
Owner

Yeah, I agree with you. There is no need to learn any additional libraries to manage React's state.

So what's your suggestion? Should I add an additional block next to Redux and MobX?

@aoc
Copy link
Author

aoc commented Jun 29, 2018

Yes, i think it's only a clarification

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

2 participants