1.每当我点击单选按钮时,它会调用handleOptionChange回调,但不会反映html的变化.2.但是当我在单选按钮上单击两次时,它反映了更改
我的问题是为什么我需要在单选按钮上单击两次?我做错了吗?
class CompleteProfile extends Component{
constructor(props){
super(props);
this.state = {
teacher_role:'subject'
};
this.handleOptionChange = this.handleOptionChange.bind(this);
}
handleOptionChange(event){
event.preventDefault();
let { name, value } = event.target;
this.setState( { [name]:value } );
}
render(){
let { teacher_role } = this.state;
console.log('teacher:',teacher_role);
return(
<Wrapper className="complete-profile">
<CustomContainer>
<Title>complete profile</Title>
<ProfileCard>
<Form noValidate>
<FormGroup>
<label>I want to enroll as:</label>
<label htmlFor="test">
<input id="test" type="radio" name="teacher_role" value="subject" checked={ teacher_role === 'subject' } onChange={ this.handleOptionChange } />
subject teacher
</label>
<label htmlFor="test1">
<input id="test1" type="radio" name="teacher_role" …Run Code Online (Sandbox Code Playgroud) 为什么 hot-update.json 文件挤满了我的项目目录
每次当我使用这个命令在开发模式下运行 webpack,webpack -d --watch然后在 app.js 文件或任何其他文件中进行任何更改时,webpack 正在观察它编译它并在 dist 目录中添加hot-update.json文件。
我正在使用使用 fetch 库的 react 样板。但是现在我想实现拦截器,有没有人知道如何使用 fetch 库来实现它,或者我应该为此使用 axios。