I am using props in react. And found this
var App = React.createClass({
render: function(){
var t = this.props.txt;
return(<div>
<h1> {t}</h1>
</div>);
},
});
React.render(<App txt="hi"/>, document.body);
This works fine, as variable t is inside the render function. But when placed t outside the render function like this
var App = React.createClass({
// position of t is shifted here
var t = this.props.txt;
render: function(){
return(<div>
<h1> {t}</h1>
</div>);
},
});
React.render(<App txt="hi"/>, document.body);
This does not work. Since I am invoking App directly in React.render not the function render, I expect that App should have props available. What am I missing?