Slide 33
Slide 33 text
React ESI @dunglas
Serving The Fragments (internal URL)
import express from 'express';
import { path, serveFragment } from 'react-esi/lib/server';
const server = express();
server.get(path, (req, res) =>
// "path" default to /_fragment, change it using the REACT_ESI_PATH env var
serveFragment(
req,
res,
// "fragmentID" is the second parameter passed to the "WithESI" HOC, the root component used
for this fragment must be returned
fragmentID => require(`./components/${fragmentID}`).default)
);