Slide 62
Slide 62 text
import React from 'react';
import { match, RouterContext } from 'react-router';
import { routes } from '../shared/sharedRoutes';
export default function renderView(req, res, next) {
const matchOpts = {
routes: routes(),
location: req.url
};
}
Architecture: React Router
const handleMatchResult = (error, redirectLocation, renderProps) =>
{
if (!error && !redirectLocation && renderProps) {
// render code
}
}
match(matchOpts, handleMatchResult);
renderView.jsx
match(matchOpts, handleMatchResult);
const matchOpts = {
routes: routes(),
location: req.url
};