Reactjs-更改一个下拉列表时重置下拉列表

Reactjs-更改一个下拉列表时重置下拉列表,reactjs,office-fabric,Reactjs,Office Fabric,概述: 我有3个下拉列表,用于过滤数据: <MyDropdown label="Filter by name" options={this.array1} changeState={this.event1.bind(this)}/> <MyDropdown label="Filter by name" options={this.array2} changeState={this.event2.bind(this)}/&g

概述:

我有3个下拉列表,用于过滤数据:

<MyDropdown label="Filter by name" options={this.array1}
              changeState={this.event1.bind(this)}/>
<MyDropdown label="Filter by name" options={this.array2}
              changeState={this.event2.bind(this)}/>
<MyDropdown label="Filter by name" options={this.array3}
              changeState={this.event3.bind(this)}/>

我的要求是,每当用户更改任何下拉列表时,将另一个下拉列表重置为第一个索引

我可以使用JQuery实现此功能,但是否可以通过react而不调用这些udate上的render()

更新

MyDropdown控制器(使用office结构下拉列表)

0?this.props.options[0]。键:未定义}
/>

如果希望在不调用render()函数的情况下实现dom更改

MobX提供api来处理状态更改,而无需调用setState()

其中,每个变量都将是一个可观察的,可以触发值变化,如角度2wayDataBinding

您可以使用以下npm模块

它具有所需的所有API,例如在您的案例中, 选择选项后,需要更改选项的值

         <Async
            id="state-select"
            onBlurResetsInput={false}
            onSelectResetsInput={false}
            className="team-creation-dropdown-input"
            simpleValue
            clearable={false}
            rtl={false}
            searchable
            disabled={false}
            noResultsText="No results found"
            placeholder="Last Name"
            name="selected-state"
            labelKey="last_name"
            options={this.state.salesExecutives}
            value={teamMemberDetail.id}
            onChange={e => this.addNewTeamMember(e)}
            loadOptions={(input, callback) => { this.getOptions(input, callback, 'salesExecutives'); }}
            onInputChange={searchValue => { this.salesExecutivesSearch(searchValue, 'last_name'); }}
          />
this.addNewTeamMember(e)}
loadOptions={(输入,回调)=>{this.getOptions(输入,回调,'salesExecutives');}
onInputChange={searchValue=>{this.salesExecutivesSearch(searchValue,'last_name');}
/>

通过使用此选项,您可以简单地拼接onInputChange或onChange上的值

您可以显示
我的下拉列表的代码吗?答案很大程度上取决于您的组件是受控的还是非受控的。@Chris我已经更新了post.MyDropdown是一个自定义组件?它应该只使用react完成吗?或者你可以用普通的javascript@ShubhamAgarwalBhewanewala不它的办公室织物正在下降
         <Async
            id="state-select"
            onBlurResetsInput={false}
            onSelectResetsInput={false}
            className="team-creation-dropdown-input"
            simpleValue
            clearable={false}
            rtl={false}
            searchable
            disabled={false}
            noResultsText="No results found"
            placeholder="Last Name"
            name="selected-state"
            labelKey="last_name"
            options={this.state.salesExecutives}
            value={teamMemberDetail.id}
            onChange={e => this.addNewTeamMember(e)}
            loadOptions={(input, callback) => { this.getOptions(input, callback, 'salesExecutives'); }}
            onInputChange={searchValue => { this.salesExecutivesSearch(searchValue, 'last_name'); }}
          />