Replacing ‘componentWillReceiveProps’ with ‘getDerivedStateFromProps’by@amanshu_kataria
304,385 reads
304,385 reads

Replacing ‘componentWillReceiveProps’ with ‘getDerivedStateFromProps’

by Amanshu Kataria2mMay 13th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

GetDerivedStateFromProps is a static method which is invoked after a component is instantiated as well as when it receives new props. The only way to update state is returning an object. If you don’t want to update any state, simply return null. Release of React 17 will deprecate some lifecycle methods introduced in React 16.3. For example we’re getting some data from firebase and displaying it in the form of stats. Here’s the code for the same.

Company Mentioned

Mention Thumbnail
featured image - Replacing ‘componentWillReceiveProps’ with ‘getDerivedStateFromProps’
Amanshu Kataria HackerNoon profile picture
Amanshu Kataria

Amanshu Kataria

@amanshu_kataria

Software Engineer

Learn More
LEARN MORE ABOUT @AMANSHU_KATARIA'S
EXPERTISE AND PLACE ON THE INTERNET.

Share Your Thoughts

About Author

Amanshu Kataria HackerNoon profile picture
Amanshu Kataria@amanshu_kataria
Software Engineer

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
L O A D I N G
. . . comments & more!