S.M_Emamian
S.M_Emamian

Reputation: 17393

Render reactjs with nodejs

I should use node.js. I would like to use reactjs to render my views. but there are some questions.

  1. pre-defined functions inside reactjs like componentDidMount will work?
  2. I should use redux, is it possible?
  3. which of routing I should use (react or express.js router)?

Upvotes: 0

Views: 103

Answers (2)

Chaitanya Mankala
Chaitanya Mankala

Reputation: 1704

  1. Yes
  2. Yes, It is possible
  3. react-router is for internal App routing. Where Express.js can only route to /index.html on main source.

Eg: myapp.com/reactapp -> done by Express, where index.html is on /reactapp myapp.com/myapp/new/view --> here /new/view is routed by react

Upvotes: 0

Cat_Enthusiast
Cat_Enthusiast

Reputation: 15698

1) Predefined functions like componentDidMount will totally work as well as the other lifecycle events in React.

2) Yes, it's possible, Redux is great for app-state management and preserving data to be used inside the application for each instance.

3) You should make use of both React-Router and Express. You can use React-Router to navigate on the front-end, navigating from page to page. For Express, it's especially useful for developing API routes for your backend if necessary.

Upvotes: 1

Related Questions