【问题标题】:Getting Uncaught TypeError: path.split is not a function while working with MUI in React获取未捕获的类型错误:在 React 中使用 MUI 时 path.split 不是函数
【发布时间】:2022-11-01 17:31:38
【问题描述】:
<form onSubmit={handleSubmit(onSubmit)}>
              <Box marginTop={2}>
                {textFields.map((textField) => (
                  <TextField
                    sx={{
                      my: 2,
                    }}
                    fullWidth
                    label={textField.label}
                    placeholder={textField.placeholder}
                    name={textField.name}
                    inputRef={register}
                    key={textField.label}
                  />
                ))}
              </Box>
              <Button type='submit' size='large' variant='contained' fullWidth>
                Submit
              </Button>
</form>

在 React 中使用 MUI 开发表单时,我得到了一个 Getting Uncaught TypeError: path.split is not a function。

尝试在互联网上搜索解决方案,但我并没有完全了解 MUI 部分需要做什么。

【问题讨论】:

    标签: reactjs forms material-ui


    【解决方案1】:

    需要更改参考

     <TextField ...inputRef={register}
    

    <input {...register(textField.name, { required: true })} />
    

    【讨论】:

      猜你喜欢
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 2022-09-24
      • 2015-07-20
      • 2022-11-23
      相关资源
      最近更新 更多