DEV Community

Discussion on: How to add a dynamic title on your React app

Collapse
 
rob88 profile image
Reben Faraj • Edited

if you are struggling with integrating helmet title to your project , run this command npm i helmet
once installed

simply copy and paste into a new file called TitleComponent.js in the src folder

// TitleComponent.js
import React from 'react';
import Helmet from 'react-helmet';

const TitleComponent = ({ title }) => {
var defaultTitle = '⚛️ app';
return (

{title ? title : defaultTitle}

);
};

export { TitleComponent };

and in your app.js inside return(
//paste this !!

)
// lets assume that you have a contact page

import {TitleComponent } from './TitleComponent';
paste this into contact page inside a dev
tag

Its really confused me from the beginning, let me know if you need any help with this

Happy Codding :)