Closed Hilshire closed 5 years ago
React Refs with TypeScript
工作中遇到的场景:ref 指向 antd 的 Form 组件
... import { WrappedFormUtils } from 'antd/lib/form/Form'; export default class CyclePurchaseUserSearch extends React.Component<any, any> { xForm = React.createRef<WrappedFormUtils>() handleSubmit = () => { this.xForm.current!.validateFields((err) => { ... }) } } render () {...} }
写 ts 真的会越写约觉得自己菜...
混乱邪恶(但是很爽):
xform: any = React.createRef()
React Refs with TypeScript
工作中遇到的场景:ref 指向 antd 的 Form 组件
写 ts 真的会越写约觉得自己菜...