1、代码
import React, {Component} from "react";
export default class Search extends Component {
search = () =>{
//获取用户的输入(连续解构赋值+重命名)
const {keyword:{value:keyword}} = this;
console.log('keyword',keyword)
//发送网络请求
}
render()
{
return(
<section className="jumbotron">
<h3 className="jumbotron-heading">Search Github Users</h3>
<div>
<input ref={c=>this.keyword=c} type="text" placeholder="enter the name you search"/>
<button onClick={this.search}>Search</button>
</div>
</section>
);
}
}