React开发:从服务器渲染到游戏开发的全流程指南
1. 服务器渲染与数据预取
1.1 添加服务器渲染
在接近完成开发时,还需为 Express 服务器添加数据获取功能。以下是具体操作步骤:
1. 打开 server-production.es6 文件,在文件顶部添加以下导入代码:
import { Provider } from 'react-redux'
import configureStore from './build/shared/store/configure-store'
import { fetchPostsAsync } from './build/shared/api/fetch-posts'
- 用以下代码替换
const approutes:
const appRoutes = (app) => {
app.get('*', (req, res) => {
match({ routes, location: req.url },
(err, redirectLocation, props) => {
if (err) {
res.status(500).send(err.message);
}
else if (redirectLocation) {
React游戏开发全流程指南
超级会员免费看
订阅专栏 解锁全文
970

被折叠的 条评论
为什么被折叠?



