question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Frame Element: Invariant Violation

See original GitHub issue

Describe the bug Invariant violation when running Basic example inside React App. Error occurs on <Frame> element and below.

Uncaught Error: Invariant failed: A <Element /> that is used inside a User Component must specify an id prop, eg: <Element id="text_element">...</Element>.

To Reproduce

  1. Install Basic project dependencies, and move folders to correct locations
  2. Import the index.js function export into an existing React Component.
  3. Error on load

Expected behavior The Basic Example’s main export is a function component, which should mean it is importable within an existing React App.

Your environment

Software Version(s)
craft.js 0.1.0-beta.13
React 16.12.0
TypeScript none
Browser Opera 72.0.3815.320 (Chrome 86)
npm/Yarn 6.14.5
Operating System Windows 10 x64

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

3reactions
fraankcommented, Jun 27, 2021

For me, changing

<Element id="canvas" className="canvas" canvas></Element>

to

<Element id="canvas" is="div" className="canvas" canvas></Element>

… solved it.

0reactions
denis-ismailajcommented, Aug 10, 2021

For me this issue arised when trying to have a Container-based component that accepted any children. (No is attribute on the Element tag)

What worked for me was to create a “constraint” anyway, and use that.

For example:

export const Anything = ({children}) => <div>{children}</div>

Anything.craft = {rules: {canMoveIn: () => true}}; 

Usage:

<Element canvas id="sth" is={Anything}>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Element type is invalid: expected a string ...
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but ...
Read more >
Why i get this error "Uncaught Invariant Violation: Frame ...
This function you've defined must run in the render function, and the render function must return all of the output with exactly one...
Read more >
invariant violation: tried to get frame for out of range index nan in flatlist
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >
Invariant Violation: React.Children.only expected to receive a ...
Coding example for the question Invariant Violation: Invariant Violation: React.Children.only expected to receive a single React element child-React Native.
Read more >
Error Invariant Violation registerComponent Target container ...
Uncaught Error: Invariant Violation: _registerComponent(...): Target container is not a DOM element. Here's my code: /** @jsx React.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found