-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Removed unnecessary component state, used props instead #20791
Conversation
…eFromProps, checked for props changes to trigger updates
I was looking through this component, and now I wonder if we even need to have state here at all? It just seems like it's just shortcut for |
@pieh you are probably right, the only place where it's used is in renderLanguageChoice, and is just making a comparison, it could use props for the same purpose, do you want me to change it? |
If it doesn't have any functional difference, we should change it to drop using state.
|
It even explitely calls "Unconditionally copying props to state" as anti-pattern ;) few section later |
I was using it as a replacement for componentWillReceiveProps which was already there, but since we don't even need to have a component state then the whole thing is unnecessary, if you want me I can remove the component state and just use props |
If you could do that, that would be awesome! |
@pieh okay I think it's done |
Ok, there is just that line after edited code block:
That needs a bit of adjust as we don't have state anymore - maybe something like (additionally trying to avoid language like "easy"):
(feel free to reword in different way) |
@pieh you are right!, okay I finished the text change, let me know if you want me to change anyhting else :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
I think we are good - it should automatically merge pull request now once all the checks finish |
@pieh thank you! |
Holy buckets, @alexisshriov — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
removed unnecessary component state
Description
there is no need to have a state in this component, we can use props directly
Documentation
this is part of the documentation of LanguageSwitcher, is a code example.
Related Issues