使用React和Express [英] Use React and Express

查看:43
本文介绍了使用React和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 divs inside and React components which can be rendered in those divs.

当用户选择路由时(例如/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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆