Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useForceUpdate does not exists on type #98

Open
louiskhenghao opened this issue Jun 4, 2021 · 1 comment
Open

useForceUpdate does not exists on type #98

louiskhenghao opened this issue Jun 4, 2021 · 1 comment

Comments

@louiskhenghao
Copy link

louiskhenghao commented Jun 4, 2021

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.

@sentyon
Copy link

sentyon commented Jul 1, 2021

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({}), []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants