Comments (5)
@mib008 这个看了提交记录,当时为了支持 promise callback 的方式,没办法判断是否是无状态组件还是callback ,因为都是 function
from egg-view-react-ssr.
@mib008 发了 2.5.3 ,可以通过 egg-view-react-ssr@next 验证
from egg-view-react-ssr.
@mib008 这个看了提交记录,当时为了支持 promise callback 的方式,没办法判断是否是无状态组件还是callback ,因为都是 function
我认为并不需要判断 是否是无状态组件还是callback,直接丢给React就好了,出错也是反馈React内部的错误信息。
from egg-view-react-ssr.
@mib008 你说的这个原本是没问题的。 render 时,扩展了一种 单页面 asyncData 函数调用入口方式,当初设计的时候有点缺陷,没有考虑到无状态 function与自定义区分问题,为了 支持已经在跑的项目,就没有修改
return context => {
const { Entry, createRouter, createStore } = config;
const url = context.state.url;
const router = createRouter();
const matchRoute = matchRoutes(router, url);
const promises = matchRoute.map(({ route }) => {
const asyncData = route.component.asyncData;
return asyncData ? asyncData(context, route) : Promise.resolve(null)
});
return Promise.all(promises).then(list => {
const data = list.reduce((item, result) => {
return Object.assign(result, item);
}, {});
Object.assign(context.state, data);
const store = createStore(context.state);
return () => {
return <Provider store={store}>
<StaticRouter location={url} context={{}}>
<Entry url={url} />
</StaticRouter>
</Provider>
}
});
};
from egg-view-react-ssr.
@mib008 已经发布[email protected] 标准化支持了
from egg-view-react-ssr.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from egg-view-react-ssr.