antd-form-builder icon indicating copy to clipboard operation
antd-form-builder copied to clipboard

TS Error : Property 'useForm' does not exist on type 'FC<FormBuilderInterface>

Open matart15 opened this issue 3 years ago • 3 comments

just installed and copied example code

npm install --save-dev antd-form-builder

import React from 'react'
import { Form, Button } from 'antd'
import FormBuilder from 'antd-form-builder'

export default () => {
  const [form] = FormBuilder.useForm()
  const meta = {
    fields: [
      { key: 'username', label: 'User Name' },
      { key: 'password', label: 'Password', widget: 'password' },
    ],
  }

  return (
    <Form form={form}>
      <FormBuilder meta={meta} form={form} />
      <Form.Item wrapperCol={{ span: 16, offset: 8 }}>
        <Button type="primary">Login</Button>
      </Form.Item>
    </Form>
  )
}

matart15 avatar Jul 26 '21 12:07 matart15

@matart15

  throw new Error('FormBuilder.useForm is removed. Please use Form.useForm().')

https://github.com/rekit/antd-form-builder/blob/master/src/FormBuilder.js#L143

afeiship avatar Aug 12 '21 03:08 afeiship

Oh. I see. Thank you

matart15 avatar Aug 12 '21 04:08 matart15

Looks like Readme have an old code.

matart15 avatar Aug 12 '21 04:08 matart15