Talk about becoming deflated. Meteor’s documentation makes this appear very simple, yet I just can’t figure out what I’m getting so very wrong here. My understanding, based on all I’ve read and the help I’ve received so far is that meteor will render static ssr routes first then inject the client-side routes after the initial load. This means you should have server routes and client routes.
Now, I’ve basically copied the documentation along with some suggestions I’ve found, but I just get errors, soooooo many errors. The current error is:
Warning: React.createElement: type is invalid – expected a string (for built-in components) or a class/function (for composite components) but got: <Switch />. Did you accidentally export a JSX literal instead of a component?
I apologise to everyone that has tried to help so far. I’m just not getting this and I really need to.
Path: client/main.html
<head>
</head>
<body>
<div id="react-target"></div>
</body>
Path: startup/client.js
onPageLoad(async sink => {
const App = (await import('../ui/layouts/App.jsx')).default;
ReactDOM.hydrate(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('app')
);
});
Path: startup/client-routes.js
const ClientPage = () => <h1>Client index.</h1>;
export default (
<Switch>
<Route path="/ClientPage" component={ClientPage} />
</Switch>
);
Path: startup/server.js
import App from './server-routes';
onPageLoad(sink => {
sink.renderIntoElementById(
'app',
renderToString(
<StaticRouter location={sink.request.url}>
<App />
</StaticRouter>
)
);
});
Path: startup/server-routes.js
const ServerPage = () => <h1>Server index.</h1>;
export default (
<Switch>
<Route path="/ServerPage" component={ServerPage} />
</Switch>
);
Path: imports/ui/layouts/App.jsx
const App = props => {
return <Router />;
};