无法在aoutoComplete材质用户界面中读取null的属性“ selectionEnd”

时间:2020-01-04 07:36:03

标签: reactjs autocomplete material-ui

我对autoComplete有问题 react-text-mask是这样的:

<MaskedInput
  {...other}
  ref={ref => {
    inputRef(ref ? ref.inputElement : null);
    return ref;
  }}
  mask={[
    /\d/,
    /\d/,
    /\d/,
    /\d/,
    ' ',
    /\d/,
    /\d/,
    /\d/,
    ' ',
    /\d/,
    /\d/,
    /\d/,
    /\d/,
  ]}
  placeholderChar={'\u2000'}
/>;

和autoComplete组件是这样的:

<AmountAutoComplete
  options={this.state.autoCompleteOptions.map(option => option.title)}
  renderInput={params => {
    return (
      <TextField
        value={this.props.value}
        onChange={e => {
          onValueChange(e.currentTarget.value, '');
        }}
        InputProps={{
          inputComponent: this.TextMaskCustom,
        }}
      />
    );
  }}
/>;

,错误是

无法读取null的属性“ selectionEnd” 在handleClick(useAutocomplete.js:763)

和在使用中的autocomplete.js:763出现有关inputRef的错误:

var handleClick =函数handleClick(){ if(firstFocus.current && inputRef.current.selectionEnd-inputRef.current.selectionStart === 0){ inputRef.current.focus(); inputRef.current.select(); }

1 个答案:

答案 0 :(得分:1)

我应该像这样将参数发送到textField中:

cellData.openBtn.tag = indexPath.row
cellData.openBtn.addTarget(self, action: #selector(openPressed(_:)), for: .touchUpInside)