getData = username => {
axios.post('/', { username })
.then(({ data: tweets }) => {
this.setState({ tweets });
})
.catch(console.error);
};
onFormSubmit(e) {
e.preventDefault();
this.props.getData(this.state.form.username);
}
constructor(props) {
super(props);
this.state = {
form: {
username: '',
},
tweets: [],
}
this.onFormSubmit = this.onFormSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
}
this.props.history.push({
pathname: '/template',
search: '?query=abc',
state: { detail: response.data }
})
this.props.location.state.detail;
{Object.keys(items.items).map(
(el, ind) => < li key= { items.items[el].id } > { items.items[el].label }</li>
)}
{items.items.map(item => <li key={item.id}>{item.label}</li>)}
if (window.location.hostname == 'test.ru') {
console.log('default');
}
console.log(window.location.hostname);
в поле класса?:
Или сделали бинд метода в конструкторе?