@@ -17,58 +17,17 @@ <h1>Flask React</h1>
1717
1818 < script type ="text/jsx ">
1919
20- var DynamicSearch = React . createClass ( {
21-
22- // sets initial state
23- getInitialState : function ( ) {
24- return { searchString : '' } ;
25- } ,
26-
27- // sets state, triggers render method
28- handleChange : function ( event ) {
29- // grab value form input box
30- this . setState ( { searchString :event . target . value } ) ;
31- console . log ( "scope updated!" )
32- } ,
33-
34- render : function ( ) {
35-
36- var countries = this . props . items ;
37- var searchString = this . state . searchString . trim ( ) . toLowerCase ( ) ;
38-
39- // filter countries list by value from input box
40- if ( searchString . length > 0 ) {
41- countries = countries . filter ( function ( country ) {
42- return country . name . toLowerCase ( ) . match ( searchString ) ;
43- } ) ;
20+ var HelloWorld = React . createClass ( {
21+ render : function ( ) {
22+ return (
23+ < p > Hello, World</ p >
24+ ) ;
4425 }
45-
46- return (
47- < div >
48- < input type = "text" value = { this . state . searchString } onChange = { this . handleChange } placeholder = "Search!" />
49- < ul >
50- { countries . map ( function ( country ) { return < li > { country . name } </ li > } ) }
51- </ ul >
52- </ div >
53- )
54- }
55-
5626 } ) ;
5727
58- // list of countries, defined with JavaScript object literals
59- var countries = [
60- { "name" : "Sweden" } , { "name" : "China" } , { "name" : "Peru" } , { "name" : "Czech Republic" } ,
61- { "name" : "Bolivia" } , { "name" : "Latvia" } , { "name" : "Samoa" } , { "name" : "Armenia" } ,
62- { "name" : "Greenland" } , { "name" : "Cuba" } , { "name" : "Western Sahara" } , { "name" : "Ethiopia" } ,
63- { "name" : "Malaysia" } , { "name" : "Argentina" } , { "name" : "Uganda" } , { "name" : "Chile" } ,
64- { "name" : "Aruba" } , { "name" : "Japan" } , { "name" : "Trinidad and Tobago" } , { "name" : "Italy" } ,
65- { "name" : "Cambodia" } , { "name" : "Iceland" } , { "name" : "Dominican Republic" } , { "name" : "Turkey" } ,
66- { "name" : "Spain" } , { "name" : "Poland" } , { "name" : "Haiti" }
67- ] ;
68-
6928 React . render (
70- < DynamicSearch items = { countries } /> ,
71- document . getElementById ( 'content' )
29+ React . createElement ( HelloWorld , null ) ,
30+ document . getElementById ( 'content' )
7231 ) ;
7332 </ script >
7433
0 commit comments