Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 通行证;restProps";通过反应选择_Reactjs_Typescript_React Props_React Select - Fatal编程技术网

Reactjs 通行证;restProps";通过反应选择

Reactjs 通行证;restProps";通过反应选择,reactjs,typescript,react-props,react-select,Reactjs,Typescript,React Props,React Select,问题: 我有一个简单的表单选择组件。它有几个道具,并使用React Select V2作为实现层。我想传递一些额外的道具。代码如下: const SelectDropdownField = ({ prop1, prop2. ...restProps }: SelectProps): JSX.Element => ( <Field name={name} render={({ field, form: { setFieldValu

问题: 我有一个简单的表单选择组件。它有几个道具,并使用React Select V2作为实现层。我想传递一些额外的道具。代码如下:

const SelectDropdownField = ({
  prop1,
  prop2.
  ...restProps
}: SelectProps): JSX.Element => (
  <Field
    name={name}
    render={({
      field,
      form: { setFieldValue, setFieldTouched, errors, touched }
    }: FieldProps<FormikValues>): ReactNode => (

      return (
        </div>
            <ReactSelect
                .. //someFieldsHere
                {...restProps} // this doesn't work
            />
            {JSON.Stringify({...restProps}, null, 2)} // this works
        </div>
      );
    }}
  />
);
const SelectDropdownField=({
建议1,
建议2。
…其他道具
}:SelectProps):JSX.Element=>(
(
返回(

不幸的是,在看了代码之后,这似乎是不可能的


通过检查react select的render函数,我们可以看到添加自定义道具的唯一方法是通过
commonProps
对象。但是检查每个子组件,它没有到达DOM的位置。只有
innerProps
到达DOM,但库用户无法控制它。

非常感谢。我尝试了exp使用内部道具也进行了验证,但没有运气。似乎该组件,至少对我来说,只列出了可用道具,并且让您无法控制添加额外的东西。谢谢您的时间。。