In the world of Hooks, the componentDidMount and componentDidUpdate life cycle methods are combined in the useEffect Hook, which—when not specifying a dependency array—triggers whenever any props in the component change.
So, instead of using a class component, we can now define a function component with an Effect Hook, which does the same thing as before. The function passed to the Effect Hook is called "effect function":
import React, { useEffect } from 'react'
function App ({ title }) {
useEffect(() => {
document.title = title
})
return (
<div>Test App</div>
)
}
And that's all we need to do! The Hook that we have defined will call our effect function every time any props change.