Skip to content

Commit c11dfce

Browse files
committed
Update
1 parent 5fe1b73 commit c11dfce

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
## django-react
2-
3-
This project uses webpack to bundle all JS components (along with CSS). Once bundled, they are rendered on the server and then can be accessed through ```{{ raw rendered }}``` tag.
4-
51
### Rendering
6-
Server-side rendering is a very simple concept -- you create a node.js server that looks for Reactjs components, renders them (usually using ```React.renderToString```) and returns the output in HTML format. This is very simple and can be implemented without the use of other packages. All that is required is a node server (```render.js```) and a ```package.json``` file with its dependencies.
2+
Server-side rendering is a very simple concept -- you create a node.js server that looks for Reactjs components, renders them (usually using ```React.renderToString```) and returns the output in HTML format. This is very simple and can be implemented without the use of other packages. All that is required is a node server (```render.js```) and a ```package.json``` file with its dependencies. Babel is used as well in order to transform JSX into JS and ES6 into ES5 (letting us use 'tomorrows features, today').
73

84
Projects like ```react-render``` ([repo](https://github.com/mic159/react-render/)), and ```python-react``` ([repo](https://github.com/markfinger/python-react)), allow the user to input the prerendered JSX through native python, which is then caught by the node server, which uses json to render the JSX, along with the python package ```requests``` to return it as a string. This allows the code to look like more native python:
95

@@ -70,5 +66,9 @@ npm run react-service
7066
```
7167

7268
### Conclusion
69+
- Python HTTP API sends bundle to node server
70+
- Node server recieves component
71+
- Returns rendered bundle
72+
- Import and use in templates
7373

7474
After much research and toying with different tools, using a node.js service along with webpack is the best solution for replacing Django's frontend. Using Django solely as an API once React has been implemented is also best practice (remember, JSX files render both JS and HTML). Webpack rocks, and React is the future of front end. Thanks for reading :)

0 commit comments

Comments
 (0)