My question is very simple. If I have a class in ES6, is it possible to use the arrow function inside it?
import React, { Component } from 'react';
export default class SearchForm extends Component {
state = {
searchText: ''
}
onSearchChange = e => {
this.setState({ searchText: e.target.value });
}
handleSubmit = e => {
e.preventDefault();
this.props.onSearch(this.query.value);
e.currentTarget.reset();
}
render() {
return (
<form className="search-form" onSubmit={this.handleSubmit} >
<label className="is-hidden" htmlFor="search">Search</label>
<input type="search"
onChange={this.onSearchChange}
name="search"
ref={(input) => this.query = input}
placeholder="Search..." />
<button type="submit" id="submit" className="search-button">
<i className="material-icons icn-search">search</i>
</button>
</form>
);
}
}
The reason I'm asking is because I get an error message in my console, even when using Babel. It looks like there are many resources on the Internet that say you can do this (most of which are dedicated to developing using React).
Is this what Babylon must do and eventually become natively supported?
The error I get is an unexpected = sign, right in front of the pars.
: , , this . - - this . .