DEV Community

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

Collapse
 
alfredosalzillo profile image
Alfredo Salzillo • Edited
// routes.js

import React from 'react';
import { Route } from 'react-router';
import { TitleComponent } from './TitleComponent.jsx';

// withTitle function
const withTitle = ({ component: Component, title }) => {
    return class Title extends Component {
        render() {
            return (
                <React.Fragment>
                    <HelmetComponent title={title} />
                    <Component {...this.props} />
                </React.Fragment>
            );
        }
    };
};

I think you have mistakenly used HelmetComponent instead of TitleComponent.

Collapse
 
luispa profile image
LuisPa

Great observation, fixed!