Skip to content

Warning: "Expected static flag was missing" when rendering an empty object {} initially #47

@jortizhbr

Description

@jortizhbr

Basically, when I render the <JsonView /> component for the first time, my default value is an empty object {}. When that value changes React strict mode throws the following warning:

Warning: Internal React error: Expected static flag was missing. Please notify the React team. Error Component Stack

As a workaround I made the default value a nested object and that made the warning go away.

Here is a small component that triggers the warning:

const JsonViewer: React.FC = () => {
  const [json, setJson] = useState({});

  useEffect(() => {
    setJson({ "": { "": null } });
  }, []);

  return <JsonView data={json} shouldExpandNode={collapseAllNested} />;
};

I'm using react-json-view-lite version 2.3.0 and React 18.2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions