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

How to save data from a custom component

Open Sandlee09 opened this issue 3 years ago • 1 comments

Anyone know how to save the input's data from a custom component

I added a custom component and its taking in the props correctly but I don't know how to safve the data, it simply never saves the data like other built in inputs do.

Sandlee09 avatar Oct 28 '22 19:10 Sandlee09

There is example of custom component https://github.com/Kiho/react-form-builder/blob/master/examples/custom/app.js#L14

const MyInput = React.forwardRef((props, ref) => {
  const { name, defaultValue, disabled } = props;
  return <input ref={ref} name={name} defaultValue={defaultValue} disabled={disabled} />;
});

Your custom component should have input element with ref associated with it.

Kiho avatar Oct 31 '22 15:10 Kiho