使用React和Express [英] Use React and Express
问题描述
我正在NodeJS(由Heroku托管)上使用Express框架来创建我的网站.我也在使用React框架来创建我的组件.
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 components.
我有几个带有div
的HTML文件,以及可以在这些div
中呈现的React组件.
I have several HTML files with div
s inside and React components which can be rendered in those div
s.
当用户选择路由时(例如/movies
),我希望能够将一个HTML文件与组件相关联并将其返回给用户.我已经在寻找解决方案,但是他们都谈论服务器端渲染和发送回HTML文件.
When a user chooses a route (e.g. /movies
) I want to be able to associate one HTML file with a component 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?
推荐答案
Check out react router you don't have to use server side rendering, you just need to give a react component that you want to return when a route is requested.
这篇关于使用React和Express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!