0

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!

1 Answer 1

0

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]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.