When creating an effect in React, avoid arrow function and instead use a function with a name. This will
Show the function name in the stack trace of an error
Help you and your team know what this effect does
Force you to only use this effect for one concern
React.useEffect(
function changeDocumentTitle() {
const currentTitle = document.title;
document.title = title;
return function restoreDocumentTitle() {
document.title = currentTitle;
};
},
[title]
);