Dealing with legacy lifecycle methods
See original GitHub issueAs mentioned in https://github.com/freeCodeCamp/freeCodeCamp/pull/35894 and https://github.com/freeCodeCamp/freeCodeCamp/pull/35895#issuecomment-508145165 there are still challenges that use legacy React lifecycle methods.
Let’s discuss what we should do with those challenges.
Personally, I think the challenge that uses them should simply be removed. Quoting the React blog:
some of our legacy component lifecycles tend to encourage unsafe coding practices
So, not something we need to teach.
The other challenge has componentWillReceiveProps
, but it is not integral to the challenge. If the method is removed, I think that challenge will be fine.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
React.Component
Each component has several “lifecycle methods” that you can override to run code ... This method is considered legacy and you should avoid...
Read more >Unsafe legacy lifecycle methods should not ... - Rule | DeepScan
This rule applies when unsafe legacy lifecycle methods are defined together with newly added replacements. In React v16.3, componentWillMount() ...
Read more >Understand Life Cycle Methods in React.js - Medium
To build a project using React, the first step is to figure out the various Components that are required to bring your project...
Read more >How to Work Effectively With Legacy Code - Perforce Software
4. Try Refactoring Instead · Refactor code that has unit tests — so you know what you have. · Start with the deepest...
Read more >Understanding React v16.4+ New Component Lifecycle ...
componentWillMount. All the legacy use cases are covered in the constructor. · componentWillReceiveProps. The new static method ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jonathan-grah As I understand it, there’s no point making significant changes since those changes will only be temporary. However, these changes would be pretty trivial.
@thecodingaviator isn’t it worth keeping “Optimize Re-Renders with shouldComponentUpdate”? The fix is pretty simple. We delete
from the seed and solution and change “the other lifecycle hooks are triggered” to “the lifecycle hooks are triggered”. I’d be happy to create the PR for this.
@ojeytonwilliams I’m onboard with that, I think you should go ahead and make the PR