I’m trying to use react-router based on Level 2 Meteor + React #2 - React Router - YouTube. I had to rename files a little bit as this tutorial does not reflect my default tree.
I made imports/ui/route.js with the following content:
import React from ‘react’;
import {
Router,
Route,
IndexRoute,
browserHistory
} from ‘react-router’;
import { render } from ‘react-dom’;
import App from ‘./App’;Meteor.startup(() => {
render(
,
document.getElementById(‘react-target’));
});
And changed main.jsx to the following:
import React from ‘react’;
import { Meteor } from ‘meteor/meteor’;
import { render } from ‘react-dom’;
// import { App } from ‘/imports/ui/App’;import ‘…/imports/ui/routes’
Initially I got the following error: “TypeError: Cannot read properties of undefined (reading ‘pathname’)” …based on this: reactjs - React Router: Cannot read property ‘pathname’ of undefined - Stack Overflow I changed the “Router” import to “BrowserRouter as Router” import. The following error was left: “React.createElement: type is invalid – expected a string (for built-in components) or a class/function (for composite components) but got: undefined.”
With this last error, I reached the help page: javascript - React JS - Route - Element type is invalid - Stack Overflow …I tried to change import { Router } to import Router, but this was useless, giving me other errors.
How to use react-router with Meteor and React in the similar manner as given in this manual?