October 2019
Intermediate to advanced
426 pages
11h 49m
English
If you have worked with React before, you have probably used the componentDidMount and componentDidUpdate life cycle methods. For example, we can set the document title to a given prop as follows, using a React class component. In the following code section, the life cycle method is highlighted in bold:
import React from 'react'class App extends React.Component { componentDidMount () { const { title } = this.props document.title = title } render () { return ( <div>Test App</div> ) }}
This works fine. However, when the title prop updates, the change does not get reflected in the title of our web page. To solve this problem, we need to define the componentDidUpdate life cycle method (new code ...
Read now
Unlock full access