App.js 有一个链接 - 我不明白我是否需要动作创建者/减少者?如果是这样,如何将它与服务器端渲染连接起来?
基本上加载 otherComponent - 应该通过路径从 server.js 进行 API 调用并将响应注入回组件 - 反应动作在这张图片中的位置是什么?
server.js:
app.get('/test', (req, res) => {
res.send(<otherComponent />); -> this is returning json right now? How to handle this path for example here - where this should make an api call.
});
app.get('*', (req, res) => {
res.send(`
<!doctype html>
<html>
<head>
<title>My website</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id='app'>${renderToString(
<Provider store={createStore(reducers)}>
<StaticRouter location={req.url} context={{}}>
<App />
</StaticRouter>
</Provider>
)}</div>
<script src='bundle.js'></script>
</body>
</html>
`);
});