Skip to content

Unpredictable data change #2260

Open
@jankvapil

Description

@jankvapil

Describe the bug

When I quickly click a button, sometimes the previous state is logged to the console. I can never be sure that I'm accessing actual form data (or at least I don't know how to get to them since there is no real reference to them or to the form)

const initialData = {
  name: 'Max Power',
};

const ClearFormExample = () => {
  const [data, setData] = useState(initialData);

  return (
    <div>
      <JsonForms
        schema={schema}
        uischema={uischema}
        data={data}
        renderers={materialRenderers}
        cells={materialCells}
        onChange={({ data, _errors }) => setData(data)}
      />
      <Button onClick={() => console.log(data)} color='primary'>
        Print data
      </Button>
    </div>
  );
};

Expected behavior

It would be nice to be able to directly access the internal state of the form by reference

Steps to reproduce the issue

  1. Just try the modified example from the docs

Screenshots

No response

Which Version of JSON Forms are you using?

v3.1.0

Framework

React

RendererSet

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions