Skip to content

Commit b093328

Browse files
author
wzhu
committed
Last commit from Conviva laptop
1 parent da7b55c commit b093328

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

client/component/app.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
import React from "react";
22

3-
const App = () => {
4-
return <div>Hello World</div>
5-
};
3+
class App extends React.Component {
4+
constructor(props) {
5+
super(props);
6+
this.state = {
7+
id: null,
8+
name: null
9+
};
10+
}
11+
12+
componentWillMount() {
13+
fetch('/data/hello_world')
14+
.then(res=>res.json())
15+
.then(data=>{
16+
this.setState({
17+
id: data.id,
18+
name: data.name
19+
});
20+
})
21+
}
22+
23+
render() {
24+
return <div>
25+
{ this.state.id }
26+
{ this.state.name }
27+
</div>;
28+
}
29+
}
630

731
export default App;

server/static/bundle.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/static/webpack-stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"status":"done","chunks":{"main":[{"name":"bundle.js","path":"/Users/wzhu/Documents/Github/django-reactjs-env/static/bundle.js"}]}}
1+
{"status":"done","chunks":{"main":[{"name":"bundle.js","path":"/Users/wzhu/Documents/Github/django-reactjs-env/server/static/bundle.js"}]}}

server/templates/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<!doctype html>
2-
<html class="no-js" lang="">
2+
<html lang="">
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="x-ua-compatible" content="ie=edge">
6-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
76
</head>
87
<body>
98
{% load render_bundle from webpack_loader %}

server/urls.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@
1818

1919
from django.views import generic
2020

21+
22+
def hello_world(request):
23+
from django.http import JsonResponse
24+
return JsonResponse({
25+
'id': 'hello',
26+
'name': 'world'
27+
})
28+
2129
urlpatterns = [
2230
url(r'^admin/', admin.site.urls),
23-
url(r'^index/', generic.TemplateView.as_view(template_name='index.html'))
31+
url(r'^index/', generic.TemplateView.as_view(template_name='index.html')),
32+
url(r'^data/hello_world', hello_world)
2433
]
34+

0 commit comments

Comments
 (0)