0

I am using react helmet async for changing my document title. The problem is, my home page is at route /home and on button link it will take the use about page. The about component is being rendered but the problem is my document title in browser is still the same.. When i reload the page, it shows About as document title but when coming from home component. So i found a solution using Hooks.

useEffect(() => {
     document.title = "About Page";  
   }, []);

But what i need to know is should i run the clean up function wherever i call this use effect Hook.

Nijesh
  • 99
  • 12
  • 1
    https://stackoverflow.com/questions/64009029/how-to-dynamically-change-the-title-of-a-website-in-react-js-also-in-source-cod Add the helmet in your page root component, add it in both your about page and home page. – sojin Oct 22 '21 at 11:55
  • I am using async version. And I have already added helmet in App, home and also in about – Nijesh Oct 22 '21 at 11:57
  • So it should work without the above useEffect – sojin Oct 22 '21 at 11:59
  • It doesn't.. Thats my problem. It actually changes the title but its not updated.. When i reload i i can see my title as i set – Nijesh Oct 22 '21 at 11:59
  • 1
    please add your sample code in slackbits or any similar application, so that we can check – sojin Oct 22 '21 at 12:02

0 Answers0