Skip to content

Instantly share code, notes, and snippets.

@wasabigeek
Last active October 12, 2017 04:26
Show Gist options
  • Save wasabigeek/90437eaebf439ea18b2326a941fb14c5 to your computer and use it in GitHub Desktop.
Save wasabigeek/90437eaebf439ea18b2326a941fb14c5 to your computer and use it in GitHub Desktop.
An Incremental Approach to React with Django: React-Router - Before Refactoring
<!-- /templates/app/a.html -->
<div id="reactComponent"></div>
<!-- /templates/app/b.html -->
<div id="reactComponent"></div>
// /static/js/app/a.js
ReactDOM.render(
<PageAComponent/>
document.getElementById('reactComponent')
)
// /static/js/app/b.js
ReactDOM.render(
<PageBComponent/>
document.getElementById('reactComponent')
)
# /app/urls.py
urlpatterns = [
url(r'^a/', TemplateView.as_view(template_name="/app/a.html")),
url(r'^b/', TemplateView.as_view(template_name="/app/b.html")),
]
# /project/urls.py
urlpatterns = [
url(r'^app/', include('app.urls', namespace='app')),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment