Nextjs似乎不可以使用Suspense
今天准备把一个异步加载的组件用Suspense
,结果似乎不行。
报错如下:
ReactDOMServer does not yet support Suspense.
后来又搜到一个帖子,看来是确定了:
https://spectrum.chat/next-js/general/suspense-support~f83c5c32-cb4d-419e-ba3d-f08948e63584
今天准备把一个异步加载的组件用Suspense
,结果似乎不行。
报错如下:
ReactDOMServer does not yet support Suspense.
后来又搜到一个帖子,看来是确定了:
https://spectrum.chat/next-js/general/suspense-support~f83c5c32-cb4d-419e-ba3d-f08948e63584
- It is rendered once on the server - it is the root of your app
- App's getInitialProps is called before anything else - even before getInitialProps in _document.js
- It is created and mounted ONLY ONCE on the client - when the page first loads. Thereafter, on page navigation, App.getInitialProps is called before each page, and then its render function is called, to render the incoming page.
我不是个人开发者,最多算半个,毕竟有一份正式的工作,这个应该是 side project。最近在做一个 blog,实现 Headerless CMS + React 这个概念。
这不是我第一个 side project,但却是我坚持最久,并且实现最完整的一个,而且确实克服了很多困难。
主要原因是用了一个 Github 的 feature:Project,其实就是简版的 Jira。
我每次想到什么好的点子,要修复的 bug,或者想要实现的 feture,都记录下来。然后一个个解决,当把已经解决的问题挪到“Closed”栏的时候,还是很有成就感的。
而且每个问题,有优先级,排个先后顺序。
这样真正可以把项目一点一滴向前推进。
看新闻,有一个小公司叫做Zingle
,可以给公司发短信,比如定酒店、叫客房服务,甚至买咖啡,最近被收购了,4200万美元现金。
挺好玩的,但说明什么,这个idea其实就是多渠道客户服务对接系统
,比如你有个twitter账户,有人在twitter上at你们公司,对吧, 订酒店,买咖啡等等。我自己给取了一个英文名称,Multi-Channel Customer Engaging System
,也不知道对不对。
那么,既然短信可以,能不能email呢?facebook呢?公司的博客系统呢?Whatsapp ? Facebook Messager? Instagram ? 等等,你们公司在一切社交网络上的账户,能不能用来为客户提供服务呢?
这注定是个脏活累活,但这显然是有钱途的活。
新闻如下:
最近沉迷 SSR,因为考虑到了一些需求:
当然了,谷歌牛逼,都能直接解析 SPA 了,但问题我主要还是一个用户体验上:用户点击一个 url,SPA 就 404 了,但一个体验很好的网站,显然希望是能够加载出来的。下面是Vuejs
的SSR网站对SEO问题的解释:
Better SEO, as the search engine crawlers will directly see the fully rendered page.Note that as of now, Google and Bing can index synchronous JavaScript applications just fine. Synchronous being the key word there. If your app starts with a loading spinner, then fetches content via Ajax, the crawler will not wait for you to finish. This means if you have content fetched asynchronously on pages where SEO is important, SSR might be necessary.
所以就开始了迁移,从 React SPA 迁移到 nextjs。
nextjs 很多大坑,比如说:
getInitialProps 只能在pages这个目录下用
关于 router:
PM2 部署
Webpack配置的坑:
next.config.jsde 问题
.env
,而要用这个配置文件里的env
一些迷