Simple react render is not working
Ad
Here I am trying to display a simple dropdown.I come to know getInitialState
also not working.I spent some hours on it.Can you please explain it? Thank you.
var dropdown = React.createClass({
getInitialState:function() {
console.log('tr1');
return {
data2:[]
};
},
componentDidMount: function() {
console.log('tr2');
$.get(this.props.source, function(result) {
if (this.isMounted()) {
this.setState({
data2:result.data,
});
}
}.bind(this));
},
render:function() {
console.log('tr1');
console.log(this.state.data2);
return (
<div>
<h3>Select portfolio </h3> <br/>
<select onChange = {this.handleSelectChange}>
<option>any-select</option>
</select>
</div>
);
}
});
ReactDOM.render(<dropdown source="http://improwised.cgc.com/portfolios?token=yR225Y" />, document.getElementById('hello1'));
Ad
Answer
Ad
Change dropdown
to Dropdown
, because it is React component and should start from uppercase letter
Ad
source: stackoverflow.com
Related Questions
Ad
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad