You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.
After seeing the issue that @web2033 reported (#241) about deprecated lifecycle methods, I decided to go through the lifecycle challenges, and I have a few recommendations that I think would be beneficial.
This might be a little nitpicky, but I would like to see the challenge name specify that we are adding event listeners in the componentDidMount method. I know that I sometimes need to go back to old challenges to remember things that I learned and I think this could help users to more quickly identify that challenge if they need too.
The challenge asks you to use the componentWillUnmount method without a good description of that lifecycle method and when it gets called. I would argue that we should have a separate challenge later on that references this challenge and explains the method separately. This way we aren't trying to teach 2 different principles in one challenge, and the chalenges will flow nicely from mounting to updating to unmounting.
I think that we should replace componentWillReceiveProps with getSnapshotBeforeUpdate. I know that getDerivedStateFromProps is a better replacement for componentWillReceiveProps in practice, but this isn't a use case for it anyway.
"You'll need to pass nextProps as an argument to this method..." This phrasing is confusing and makes it sound like the user needs to pass nextProps when calling the method. It might be better to say something like, "nextProps will be automatically passed when this method is called so you will need to include it in the method signature in order to use it in the body of your method."
@web2033 Thanks for that article. It looks like pretty much all use cases for componentWillMount can be migrated using constructor or componentDidMount. Maybe in the first challenge we could have them console.log() something in the constructor, and explain that this is the first method that gets called in the lifecycle.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
After seeing the issue that @web2033 reported (#241) about deprecated lifecycle methods, I decided to go through the lifecycle challenges, and I have a few recommendations that I think would be beneficial.
https://learn.freecodecamp.org/front-end-libraries/react/use-the-lifecycle-method-componentwillmount/
getDerivedStateFromProps
in this first challenge then I think it's important to point out 2 things.this
).constructor
lifecycle method for this first challenge as it is the first method to be called in the lifecycle.https://learn.freecodecamp.org/front-end-libraries/react/use-the-lifecycle-method-componentdidmount
https://learn.freecodecamp.org/front-end-libraries/react/add-event-listeners
componentDidMount
method. I know that I sometimes need to go back to old challenges to remember things that I learned and I think this could help users to more quickly identify that challenge if they need too.componentWillUnmount
method without a good description of that lifecycle method and when it gets called. I would argue that we should have a separate challenge later on that references this challenge and explains the method separately. This way we aren't trying to teach 2 different principles in one challenge, and the chalenges will flow nicely from mounting to updating to unmounting.https://learn.freecodecamp.org/front-end-libraries/react/manage-updates-with-lifecycle-methods
componentWillReceiveProps
withgetSnapshotBeforeUpdate
. I know thatgetDerivedStateFromProps
is a better replacement forcomponentWillReceiveProps
in practice, but this isn't a use case for it anyway.https://learn.freecodecamp.org/front-end-libraries/react/optimize-re-renders-with-shouldcomponentupdate
componentWillReceiveProps
should be removed entirely from the contents of this challenge.We should add another challenge here that goes over
componentWillUnmount
and what it is used for.Does anyone have any thoughts or suggestions on this topic?
The text was updated successfully, but these errors were encountered: