codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Written by Arfat Salman

Passionate CS Educator | Software Developer

Responses (20)

Write a response

In other cases, you can use componentWillReceiveProps lifecycle method to keep the state and props in sync, as shown here.

In Reac 16 componentWillReceiveProps is deprecated and will be removed later. getDerivedStateFromProps then is used for update state from props.

--

For 1-st point, you can also use decorators to avoid manual adding “bind” to constructor https://www.npmjs.com/package/lodash-decorators#bind (bindAll for whole class)or https://github.com/andreypopp/autobind-decorator

--