reactjs - Office ui Fabric People Picker,将变量传递给 onChangeEvent
问题描述
我想知道是否有可能将变量添加到 office ui fabric react People Picker 组件的默认 onchange 事件中。
在 onchange 事件中默认是onChange?: (items?: IPersonaProps[]) => void
我想传递一个变量以添加到像键值这样的数组中,以便稍后在我的代码中使用。
解决方案
您可以构建一个 HOC 来实现这一点。
定义
// Your HOC component
interface Props {
yourCustomState: string // get custom value from props
...
return (
<>
<Select
onChange={(e: any) => onChange(e, yourCustomState)} // add custom value to callBack function
...
用法
handleOnChangeEvent = () => (event, yourCustomStateValue: string) => {
console.log(yourCustomStateValue);
... // event
}
<YourComponent
yourCustomState={value}
onChange={this.handleOnChangeEvent()}
...
推荐阅读
- pagination - 如何在 Angular 6/7 中使用 ngb-pagination 在 [collectionSize] 中设置动态值?
- node.js - Sequelize:如何获取日期时间列值作为字符串
- intel-pin - Pin:在同一个地址插入两条不同的指令
- php - Cakephp 3:DomPdf 的问题
- c - C为什么将数组的第一个地址传递给char指针提供整个字符串?
- javascript - 如何从本地存储中的数组中删除对象?
- javascript - 如何使用正则表达式 javascript 获取最后一次出现?
- c# - 两个数组的组合
- react-native - 反应原生的pt大小
- android - 条码库在某些情况下会扫描不相关的条码值