Deprecated methods in React

Deprecated methods in React
0

#1

https://learn.freecodecamp.org/front-end-libraries/react/use-the-lifecycle-method-componentwillmount
teaches deprecated React methods like:

componentWillMount,

componentWillUpdate,

componentWillReceiveProps

They deprecated since 16.3 and will be removed in 17

Info: https://reactjs.org/blog/2018/03/29/react-v-16-3.html


#2

Right.

FCC is teaching the version of React that was active when the curriculum was being developed. And these techniques will continue to work for people who are using the older versions of those packages. Many libraries have deprecated features that work with older versions but not with the newer ones - this is a fact of life in web dev where all these packages are developing independently and sometimes have breaking changes, sometimes changes that break other libraries. Sometimes you have to find the right combination of versions. Without a crystal ball, it is impossible to predict for sure what React will look like in a few years.

But if you think it is a big enough issue, you can raise it on github. I see that there is an old post about someone mentioning that in the code issues, but I don’t see anyone that has brought it up in the curriculum.


#3

I happened to read the official React docs so I spotted it.
But I’m not sure that even 5% of people have read the spec)


#4

Probably true. But like I said, it would get more attention if posted on the git.


#5

@web2033 and @kevinSmith I’m at this point in the curriculum and am curious to know how to do it with React 16.3+. The diagram @web2033 added to the GitHub issue is helpful.

Can either of you (or anyone else) elaborate a little more on the newer ways to do this in a way that uses the new methods replacing what’s used in the fCC curriculum? Thanks! :100:

Here are the challenges:


#6

Those methods replace the older ones from 16.3 on, but that does not mean that the old ones will disappear. There will be legacy code for years to come. Many companies will chose to stick with their old revs of React to avoid breaking changes. Some will upgrade but just globally replace the old deprecated methods the new “UNSAFE” legacy methods. I would suggest that any React dev needs to know the old methods too.

There is already a discussion on github about how to handle this. In the mean time, I’d just learn what fcc has and if you want you can learn the new methods on your own until fcc gets updated. If you understand the old methods, the new ones will pretty easy to learn.