Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non string literal Element id result in corrupt json #648

Open
eschiebel opened this issue May 28, 2024 · 2 comments
Open

Non string literal Element id result in corrupt json #648

eschiebel opened this issue May 28, 2024 · 2 comments

Comments

@eschiebel
Copy link

Describe the bug
The documentation states that an id prop is required on Element if used within a user component. This seems to work find if the id is set to a fixed string literal like id="bottom" but the json gets corrupted if set via a variable.

To Reproduce
In the basic example

  1. Edit examples/basic/components/user/Card.js
  2. in the definition of Card, add const [bottomid] = useState(window.crypto.randomUUID()); then change the Element id for CardBottom from id="bottom" to id={bottomid}
  3. on the demo page drag a new Card onto the page, then drag a new Button into the CardBottom.
  4. Click "copy current state", then "load" and paste.
  5. See that the button you dragged into the Card is not present.

Expected behavior
I should either be able to programmatically set an Element id, or the documentation should state this needs to be a string literal

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Your environment

Software Version(s)
craft.js 0.2.0 and 0.2.6
React 16.14.0
TypeScript
Browser
npm/Yarn
Operating System
@eschiebel eschiebel changed the title Non string literal Element id breaks the page Non string literal Element id result in corrupt json May 28, 2024
@dbjpanda
Copy link

Honestly, their basic example code needs a severe fix. Nothing works for me. Outdated Material ui etc in the example + this missing Element id error.

@eschiebel
Copy link
Author

Sure, but I just leveraged the basic example as the shortest path to recreating the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants