我使用 Ant Design 运行 React 并收到此错误:
'useForm' 创建的实例没有连接到任何 Form 元素。忘记传递“表单”道具?

代码:
// .../services/index.js
export { default as registerService } from './registerService'
// .../services/registerService.js
import axios from '../../../configs/api.service'
const registerService = (form) => {
return {
validatePasswordAndConfirmPassword: async (rule, value) => {
if (value && value !== form.getFieldValue(['user', 'confirmPassword'])) {
throw new Error('Password and Confirm Password must be same')
}
},
register: async user => {
const { data } = await axios.post('/users', user)
const { _id, username } = data …Run Code Online (Sandbox Code Playgroud) 完整代码: https: //gitlab.com/fResult/countries-workshop/-/blob/bug/src/pages/Countries/index.tsx
\nimport * as ApiCountries from \'../../services/APIs/countries.api\'\n\nfunction Countries() {\n const findCountriesCallback = useCallback(() => ApiCountries.findAll(), [])\n const { execute: fetchCountries, value: countries } = useAsync(findCountriesCallback)\n\n useEffect(() => {\n ;(async () => await fetchCountries())()\n }, [fetchCountries])\n\n return (\n <InfiniteScroll\n items={countries} // I don\'t understand why `countries` is `unknown` type\n renderEmptyList={() => (\n <div className="text-light-text dark:text-dark-text">\n No Content\n </div>\n )}\n keyExtractor={({ alpha3Code }) => alpha3Code}\n renderItem={renderItem}\n className="flex flex-col mt-8 md:flex-row md:flex-wrap gap-14 justify-between"\n …Run Code Online (Sandbox Code Playgroud) 我想单击 Card extra 中的 X 按钮以显示“确认删除 Todo 模式”。
当我单击 X 按钮时的现实,然后它可以从 Card 事件中看到“编辑 Todo 模式”。
我该如何解决?
{todos.map(todo => (
<Card
className={styles.CardTodo}
headStyle={{ textAlign: 'left' }}
bodyStyle={{ textAlign: 'left' }}
key={todo._id}
title={todo.title}
onClick={() => handleSelectTodo(todo._id)}
extra={
<Button
type="danger"
shape="circle"
style={{ color: 'white', zIndex: 10 }}
onClick={() => handleRemoveTodo(todo._id)}
>
X
</Button>
}
>
{todo.description}
</Card>
))}
Run Code Online (Sandbox Code Playgroud)
.
.
e.stopPropagation() 对我很有用。
handleRemoveTodo() 是打开另一个模态的函数。但是那个模态没有得到“Todo object”
当我删除 e.stopPropagation() 时,模态将再次获得 Todo 对象

const handleRemoveTodo = () => …Run Code Online (Sandbox Code Playgroud)