Skip to content

Instantly share code, notes, and snippets.

@nickretallack
Last active October 11, 2015 22:33
Show Gist options
  • Save nickretallack/4f2fbe4fdc124bfa08b3 to your computer and use it in GitHub Desktop.
Save nickretallack/4f2fbe4fdc124bfa08b3 to your computer and use it in GitHub Desktop.
"this" is null in my handler. Am I doing something wrong here?
import 'babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
class FileUploadPage extends React.Component {
handleSubmit(event) {
event.preventDefault();
console.log(this.refs.url.value.trim())
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<input type="text" ref="url"/>
<button>Fetch</button>
</form>
</div>
);
}
}
ReactDOM.render(<FileUploadPage/>, document.getElementById('root'));
import 'babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
var FileUploadPage = React.createClass({
handleSubmit: function(event) {
event.preventDefault();
console.log(this.refs.url.value.trim());
},
render: function() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<input type="text" ref="url"/>
<button>Fetch</button>
</form>
</div>
);
}
})
ReactDOM.render(<FileUploadPage/>, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment