reactjs - Multiple components in react -
iam new react .
var ad=react.createclass({ render:function(){ return(<b>{this.props.name}</b>) } }) var az=react.createclass({ render:function(){ return(<b>{this.props.class}</b>) } }) var aa=react.createclass({ render:function(){ return(<div> <ad name={this.props.name}/> <az name={this.props.class}/> </div>) } }) reactdom.render(<aa name="vijay" class="asd"/>,document.body)
but showing vijay not asd why? did react support pass 2 props.
your component az
expecting property called class
:
return(<b>{this.props.class}</b>)
but in code providing property name
:
<az name={this.props.class}/>
you should change class
in order work.
however, there issue. class
reserved keyword in react, should change class
else in code, example myclass
:
// 'class' changed 'myclass' in code below var az=react.createclass({ render:function(){ return(<b>{this.props.myclass}</b>) } }) var aa=react.createclass({ render:function(){ return(<div> <ad name={this.props.name}/> <az myclass={this.props.myclass}/> </div>) } }) reactdom.render(<aa name="vijay" myclass="asd"/>,document.body)
Comments
Post a Comment