useForceUpdate does not exists on type
louiskhenghao opened this issue · comments
I got this error below after updating to the latest version, may I know if there any fix for the TypeScript?
Error
Type error: Property 'useForceUpdate' does not exist on type 'FC<FormBuilderInterface> & { defineWidget: (key: string, component: any, metaConvertor?: (field: FieldType) => FieldType) => void; }'.
const [form] = Form.useForm();
const forceUpdate = FormBuilder.useForceUpdate();
^
Usage
const [form] = Form.useForm();
const forceUpdate = FormBuilder.useForceUpdate();
Temporary solution (Quick Fix)
Anyone facing this issue can actually pin the version to 2.1.2
since version 2.1.3
only added the TypeScript feature.
As a workaround, I added these lines to my functional component (based on https://github.com/rekit/antd-form-builder/blob/master/src/FormBuilder.js)
const [, updateState] = React.useState<any>(); const forceUpdate = React.useCallback(() => updateState({}), []);