a tunnel / etc • HTTP request hangs • Firewalls • ISP is interfering • A browser addon is messing with you • Your CDN is down Stuart Langridge's Flowchart
figuring out how this stuff works. Some of the code shown here isn't the easiest, or the APIs aren't that straight forward. This will change as we learn more. Don't expect this to be 100% smooth!
'./routes'; // match is responsible for matching routes against a URL // RouterContext renders the components in the matched routes import { match, RouterContext } from 'react-router';
request match({ routes, location: req.url }, (error, redirectLocation, renderProps) => { // error: given if something went wrong matching a route // redirectLocation: returned if the URL matches a redirect // renderProps: given if a route was matched and we can render ... });
renderProps that means we have a match and can render res.render('index', { // RouterContext is React Router's wrapper around our app // and renderProps contains all the info // React Router needs to render our app markup: renderToString(<RouterContext {...renderProps} />) }); } else { ... }
approaches will change over 7me. There's plenty to figure out in this space! Long term I expect frameworks to do more, and it become even easier for developers to take advantage.