I have a project in Django of an API and I want to use node js together with django and know if you can use react in conjunction with both to realize the frontend of my application and if possible it would be advisable to develop the application this way? Or which would be a better option to work with these technologies?
In django I'm using
->Django Rest Framework
Node js I want to use it to give Real-Time to my application
-->Socket.io
React
-->Redux -->React-router
Thank you very much for your time and your attention.
Solution was to abandon the single page app model, and instead let Django serve each page individually, with a root React component for each page. Our base site components that don't change between pages (eg navbar, footer) are provided by the Django templates, and the content specific to each page (eg poker interface, leaderboard) are composed within React.
For React Component
import React from 'react'
import ReactDOM from 'react-dom'
const Leaderboard = ({users}) =>
<div>
<h1>Featured Players</h1>
{users.map(user =>
<a href={`/user/${user.username}/`}>
{user.username}
</a>)}
</div>
ReactDOM.render(
React.createElement(Leaderboard, window.props), // gets the props that are passed in the template
window.react_mount, // a reference to the #react div that we render to
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.