javascript - React.js variable -
this question has answer here:
when use variable starting small letter, page showing nothing. if change variable name start uppercase (helloworld) page showing content.
<script type="text/jsx"> var helloworld = react.createclass({ render : function () { return ( <div> <h1>hello world</h1> </div> ); } }); react.render(<helloworld/> , document.body); </script>
can tell me why happening?
as of react v0.12., upper-case components react convention distinguishing between components , html tags.
from react documentation under html tags vs. react components header:
to render react component, create local variable starts upper-case letter:
var mycomponent = react.createclass({/*...*/}); var myelement = <mycomponent someproperty={true} />; react.render(myelement, document.getelementbyid('example'));
react's jsx uses upper vs. lower case convention distinguish between local component classes , html tags.
Comments
Post a Comment