You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Edit examples/basic/components/user/Card.js
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}
on the demo page drag a new Card onto the page, then drag a new Button into the CardBottom.
Click "copy current state", then "load" and paste.
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
The text was updated successfully, but these errors were encountered:
eschiebel
changed the title
Non string literal Element id breaks the page
Non string literal Element id result in corrupt json
May 28, 2024
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
Card
, addconst [bottomid] = useState(window.crypto.randomUUID());
then change theElement
id forCardBottom
fromid="bottom"
toid={bottomid}
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
The text was updated successfully, but these errors were encountered: