Comments (7)
貌似你没搞懂流程。
1、服务端渲染是个一次性的过程,只需要拿到符合预期的数据即可。通过什么方式都行,使用 useContext
是为了和客户端行为统一
2、window.INITIAL_DATA
本来就是服务端注入到客户端的数据。本身就是 context
的数据
from ssr.
感谢回答,可能我的表述不够清晰。
我的期望是在不使用useContext进行状态管理时,在 ssr-plugin-react中能直接提供combineData,以节省内存开销。
from ssr.
你指的开销是啥呢。服务端本来就不需要状态管理。除非你客户端也完全不需要跨组件通信那可以完全抛弃所有的 context
。但是基本是不存在这种情况的。
至于你说的开销,我理解使用 useContext
还是通过 props.data
的形式传入本质是一样的。服务端渲染完成后一样都会有 GC
来回收对应的内存。
from ssr.
1.因为我的实际情况,不得不使用redux
2.至于开销其实影响不大, 每次页面渲染createContext 额外添加的属性,会增加微量内存回收负担,高并发时cpu占用会增高一小点。但是不优化的话老觉得心里膈应,因为我完全用不到它,但它却存在
from ssr.
- 本框架不支持使用
redux
- 使用
useContext
是为了写法跟客户端保持一致。而且你说的完全用不到它
这句话本身就是错误的。无论是使用useContext
还是props
传值性质是一样的。 - 至于你说的内存 cpu 这些我认为是不可能会影响的,如果这点细微的差别会导致监控显著变化那除非你的 qps 高达 万级别才可能会出现。如果这点东西都会导致。。那 node 就不用玩了
from ssr.
没太搞清楚你指的开销是服务端的开销还是浏览器客户端的开销。不过无论是哪种。。基本都不可能因为这个影响
from ssr.
服务端的开销,这个开销确实几乎可以忽略不计,而且是因为我的特殊使用需求产生,我在本地解决吧,感谢
from ssr.
Related Issues (20)
- 使用antd时存在样式闪烁问题 HOT 7
- sourcemap 对应配置完善后,构建产物中未生成 sourcemap 文件 HOT 2
- 官网挂了,麻烦看一下 HOT 4
- ssr build 优化建议 HOT 3
- 框架怎么设置 productionSourceMap HOT 3
- vite编译超时 HOT 3
- 怎么引入element-plus HOT 14
- 通过 less loader 配置的 less 变量不生效 HOT 5
- 请问有没有 egg的服务端插件? 如果没有,后端想使用egg,该怎么做呢,谢谢。 HOT 5
- 访问未定义的路由时,server端代码报错
- 生产环境的antdv ui css 样式和开发环境不一致 HOT 4
- 引入 css文件 报错 HOT 17
- 请问启动后,isBrower找不到,编译报错怎么解决?谢谢 HOT 2
- npx ssr build --html 编译出错 HOT 1
- 使用midway-vue3-ssr模版在组件中访问public下的静态资源404 HOT 3
- antd5新版本的兼容性问题
- 新版本antd5兼容性问题 HOT 4
- ssr-plugin-react 新版本缺少src路径
- build:o 相关问题 HOT 9
- Pm2模式下, Require() of ES Module 报错 HOT 2
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 ssr.