GithubHelp home page GithubHelp logo

Comments (7)

zhangyuang avatar zhangyuang commented on May 21, 2024

貌似你没搞懂流程。
1、服务端渲染是个一次性的过程,只需要拿到符合预期的数据即可。通过什么方式都行,使用 useContext 是为了和客户端行为统一
2、window.INITIAL_DATA 本来就是服务端注入到客户端的数据。本身就是 context 的数据

from ssr.

SSoLMan avatar SSoLMan commented on May 21, 2024

感谢回答,可能我的表述不够清晰。
我的期望是在不使用useContext进行状态管理时,在 ssr-plugin-react中能直接提供combineData,以节省内存开销。

from ssr.

zhangyuang avatar zhangyuang commented on May 21, 2024

你指的开销是啥呢。服务端本来就不需要状态管理。除非你客户端也完全不需要跨组件通信那可以完全抛弃所有的 context。但是基本是不存在这种情况的。

至于你说的开销,我理解使用 useContext 还是通过 props.data 的形式传入本质是一样的。服务端渲染完成后一样都会有 GC 来回收对应的内存。

from ssr.

SSoLMan avatar SSoLMan commented on May 21, 2024

1.因为我的实际情况,不得不使用redux
2.至于开销其实影响不大, 每次页面渲染createContext 额外添加的属性,会增加微量内存回收负担,高并发时cpu占用会增高一小点。但是不优化的话老觉得心里膈应,因为我完全用不到它,但它却存在

from ssr.

zhangyuang avatar zhangyuang commented on May 21, 2024
  1. 本框架不支持使用 redux
  2. 使用 useContext 是为了写法跟客户端保持一致。而且你说的 完全用不到它 这句话本身就是错误的。无论是使用 useContext 还是 props 传值性质是一样的。
  3. 至于你说的内存 cpu 这些我认为是不可能会影响的,如果这点细微的差别会导致监控显著变化那除非你的 qps 高达 万级别才可能会出现。如果这点东西都会导致。。那 node 就不用玩了

from ssr.

zhangyuang avatar zhangyuang commented on May 21, 2024

没太搞清楚你指的开销是服务端的开销还是浏览器客户端的开销。不过无论是哪种。。基本都不可能因为这个影响

from ssr.

SSoLMan avatar SSoLMan commented on May 21, 2024

服务端的开销,这个开销确实几乎可以忽略不计,而且是因为我的特殊使用需求产生,我在本地解决吧,感谢

from ssr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.