React fetch data in server before render

前端 未结 8 2027
自闭症患者
自闭症患者 2020-12-02 18:29

I\'m new to reactjs, I want to fetch data in server, so that it will send page with data to client.

It is OK when the function getDefaultProps return dummy data like

8条回答
  •  被撕碎了的回忆
    2020-12-02 18:58

    Responded to a similar question with a potentially simple solution to this if anyone is still after an answer, the catch is it involves the use of redux-sagas:

    https://stackoverflow.com/a/38701184/978306

    Or just skip straight to the article I wrote on the topic:

    https://medium.com/@navgarcha7891/react-server-side-rendering-with-simple-redux-store-hydration-9f77ab66900a

提交回复
热议问题