Domanda

How to update the title tag in the Head ?

enter image description here

Really don't want to mess around with the DOM updating with javascript!

È stato utile?

Soluzione

To update <title> tag in custom component:

import { Meta, Title } from 'location-to-head-component/lib/components/Head';

Then return:

return (
        <>
            <Title>you-title-here - {yourVar}</Title>
            //page content here
        </>
    );

OR:

useEffect(() => {
      document.title = 'you-title-here - '+yourVar;
   }, [title]);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top