最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Use React and Express - Stack Overflow

programmeradmin3浏览0评论

I'm using Express framework on NodeJS (hosted by Heroku) to create my web site. I'm also using the React framework to create my ponents.

I have several HTML files with divs inside and React ponents which can be rendered in those divs.

When a user chooses a route (e.g. /movies) I want to be able to associate one HTML file with a ponent and return it back to the user. I already looked for a solution, but all of them talk about server-side rendering and sending back HTML files.

Is there another solution?

I'm using Express framework on NodeJS (hosted by Heroku) to create my web site. I'm also using the React framework to create my ponents.

I have several HTML files with divs inside and React ponents which can be rendered in those divs.

When a user chooses a route (e.g. /movies) I want to be able to associate one HTML file with a ponent and return it back to the user. I already looked for a solution, but all of them talk about server-side rendering and sending back HTML files.

Is there another solution?

Share Improve this question edited Sep 18, 2017 at 10:40 moopet 6,1851 gold badge30 silver badges37 bronze badges asked Feb 23, 2015 at 6:29 ArianArian 7,74924 gold badges107 silver badges190 bronze badges 1
  • Would you be able to give more details why you need more html files? Usually if you don't want to do server-side routing one HTML file serving as a container is enough, all the other views can be rendered straight from the Javascript – Arek Flinik Commented Mar 29, 2015 at 15:20
Add a ment  | 

2 Answers 2

Reset to default 8

Check out react router you don't have to use server side rendering, you just need to give a react ponent that you want to return when a route is requested.

The standard way to do this now is to build a Single-Page applications and redirect all requests to /, and the front end routing will handle the required page to load.

发布评论

评论列表(0)

  1. 暂无评论