我有一个名为 admin.find({id:"5d089264d8aae228d7f10c1d"}).populate("users").then(data=>{
//update the fields which you would find in the data object
data.save()
//your data would be changed.
})
的React组件,我正在尝试创建一个form using antd。但是,当我构建打字稿应用程序时,出现错误。
BasicDelete
错误提示:
// This is how I am trying to create the form component
const BasicDeleteForm = Form.create({
mapPropsToFields(props: {
workFlowData: {
reason: string;
};
}) {
return {
reason: Form.createFormField({
value: props.workFlowData.reason
})
};
}
})(BasicDelete);
为什么会出现此错误?如何正确防止此错误?
答案 0 :(得分:0)
您必须在TypeScript
中指定类型:
import { Form } from 'antd';
import { FormComponentProps } from 'antd/lib/form';
interface UserFormProps extends FormComponentProps {
age: number;
name: string;
}
class UserForm extends React.Component<UserFormProps, any> {
// ...
}
const App = Form.create<UserFormProps>({
// ...
})(UserForm);
此外,每个组件都有"Use with Typescript" section。