reactjs - 组件不会重新渲染
问题描述
所以我有一个带有多个选择选项的表单。 我的表格
我从发送动作的年份中选择一个选项并调用 api 以获取显示的品牌列表。
如果我选择一个品牌并尝试选择另一个年份,它是否必须在选择时再次进行api调用?但显示相同的品牌列表?
在我的渲染函数中:
<div className='form-div'>
<Select defaultValue='-Year-' style = {{width:262}} className = 'formInput' onChange={this.handleYearSelection.bind(this)}>
{getYear(this.props.year)}
</Select>
</div>
<div className='form-div'>
<Select defaultValue='Brand' disabled={!this.state.brandVisibility} style = {{width:129}} className = 'formInput' onChange={this.handleBrandSelection.bind(this)}>
{getBrand(this.props.brand)}
</Select>
<Select defaultValue='Model' disabled={!this.state.modelVisibility} style = {{width:129}} className = 'formInput' onChange={this.handleModelSelection.bind(this)}>
{getModel(this.props.model)}
</Select>
</div>
渲染功能之前:
handleYearSelection(year){
this.setState({brandVisibility : true, year: year});
this.props.requestYear(year);
}
handleBrandSelection(brand){
this.setState({modelVisibility : true, brand: brand });
this.props.requestBrand(brand);
}
那么,我该如何解决这个问题
解决方案
推荐阅读
- linux - 无法将 ubuntu ec2 实例上的 /tmp 挂载绑定到 docker 容器
- sql - 四肢选择
- excel - 排序日期(欧洲格式)
- git - 有什么方法可以在 git 中找到我们最新的 pull commit Id 吗?
- sql - 发现一个 SQL 错误,我不知道该怎么办
- python - 在没有深度学习框架的情况下运行 GPU 进行计算
- android - Android Studio 是否可以选择自动扫描非活动选项卡以查找错误/警告/lint 等?
- php - 无法从 APi 更新高级自定义字段中的字段
- c# - 依赖注入和未使用的构造函数
- python-3.x - 连接熊猫数据框中的两列