【问题标题】:Office ui Fabric People Picker, pass varaibles to onChangeEventOffice ui Fabric People Picker,将变量传递给onChange事件
【发布时间】:2020-05-27 17:21:04
【问题描述】:

我想知道是否有可能向 office ui fabric react People Picker 组件的默认 onchange 事件添加一个变量。

在 onchange 事件中默认是onChange?: (items?: IPersonaProps[]) => void

我想传递一个变量以添加到像键值这样的数组中,以便稍后在我的代码中使用。

【问题讨论】:

  • @keikai 你如何构建 HOC?你有例子吗?

标签: reactjs spfx office-ui-fabric peoplepicker


【解决方案1】:

您可以构建一个 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()}
...

【讨论】:

    猜你喜欢
    • 2019-06-06
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 2020-11-17
    • 2012-04-29
    • 2021-05-30
    • 2020-09-18
    • 2015-03-07
    相关资源
    最近更新 更多