Open joshalling opened 6 years ago
This article has even more details with examples and suggestions for migration.
@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.
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?