question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dealing with legacy lifecycle methods

See original GitHub issue

As 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ojeytonwilliamscommented, Jul 10, 2019

@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

componentWillReceiveProps(nextProps) {
  console.log('Receiving new props...');
}

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.

0reactions
thecodingaviatorcommented, Jul 10, 2019

@ojeytonwilliams I’m onboard with that, I think you should go ahead and make the PR

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found