x-render icon indicating copy to clipboard operation
x-render copied to clipboard

[BUG]请问一下像这种FormRender在子组件里parent如何获取所有表单的输入值

Open zearth0907 opened this issue 4 years ago • 1 comments

import React from 'react';
import FormRender, { useForm } from 'form-render';

const Child= (props) => {
  const {schema} = props
  const form = useForm();

  const onFinish = (data, errors) => {
    console.log(errors, data);
  };
    return (
    <div>
        <FormRender
            form={form}
            schema={schema}
            onFinish={onFinish}
        />
    </div>
  );
}

const Parent = (props) => {
      const schemaA = {
        type: 'object',
        properties: {
          "input1": {
            "title": "简单输入框",
            "type": "string",
          },
        }
      };

    const schemaB = {
        type: 'object',
        properties: {
          "input1": {
            "title": "简单输入框",
            "type": "string",
          },
        }
      };

    return(
        <div>
            <Child schema={schemaA} />
            <Child schema={schemaB} />
        </div>
    );
};

export default Parent;

zearth0907 avatar Dec 21 '21 01:12 zearth0907

issue里不对用法做解答,可以到答疑群里咨询。

siyi98 avatar Dec 21 '21 03:12 siyi98