react-router-sitemap icon indicating copy to clipboard operation
react-router-sitemap copied to clipboard

render() is not getting called

Open cullsin opened this issue 5 years ago • 1 comments

Hello,

Seems like render() method is not getting called and I can see a empty url in the sitemap. Please suggest what I am missing over here.

sitemap-generator.js

  require('@babel/register')({
    extends: './.babelrc'
  });

  window = {
    location : {
      origin : 'localhost',
      search : '/'
    },
    addEventListener : function() {}
  }

  document = {
    addEventListener : function() {}
  }   

  const router = require('./src/containers/App/path.js').testRoute;
  const Sitemap = require('react-router-sitemap').default;

  function generateSitemap() {
    return new Sitemap(router)
      .build('localhost')
      .save('./public/sitemap.xml');
  }
  generateSitemap();

Path.js

  /** @format */

  import React from 'react';
  import { Route } from 'react-router';
  import '../../config'
  import '../../utils/i18nHelper';
  import '../../i18n';

  export class testRoute extends React.Component {
    render() {
      return  (  
        <Route>
          <Route path='/' />
          <Route path='/about' />
          <Route path='/projects' />
          <Route path='/contacts' />
          <Route path='/auth' />
          <Route exact path={this.props.t('lang_route:campaignFlow.subscriptionMessage')} />
        </Route>
      )  
    } 
  }

cullsin avatar Mar 16 '20 09:03 cullsin

Hi @cullsin,

Please check the example here and export your routes as such.

Matzu89 avatar Jul 05 '20 00:07 Matzu89