Yes, I did. It is supposed to be alright. It opens the window with the slice-simulator route, but it gives the mentioned error.
Is using Typescript a problem? My slice-simulator route is a .tsx file.
There shouldn’t be a problem with having a .tsx file instead. Did you change the code for the slice-simulator file? the one provided by the Slice Machine UI.
I may be wrong here, but it seems that when you create a Key Text field on a slice, the data generated inside mocks.json and libraries-state.json is like "some_label": "some auto generated text" but the code actually expects another structure, something like:
When trying to preview the slice with slice-simulator I get the error: TypeError: Cannot use 'in' operator to search for 'text' in e;
Checking the console for errors I got an error on index.js?22c8:113:1;
The error is on this part of the code
const asText = (richTextField, separator = " ") => {
let result = "";
for (let i = 0; i < richTextField.length; i++) {
if ("text" in richTextField[i]) {
result += (result ? separator : "") + richTextField[i].text;
}
}
return result;
};
I checked the .json files and the other fields have a different structure that matches the if clause on the code above, but the Key Text field does not.
Hopefully this helps you. If you need more information, just let me know.
What IDs are you giving to the Key text fields?
I'm using a project with the same setup and dependency versions as you but can't reproduce the use case.
I report that I am also experiencing this error. Screenshot attached.
Could this bug be a high priority to fix? This bug means unfortunately that the slice simulator cannot be used at all, nor can screenshots be generated or pushed to Prismic as a result.
And is there a temporary measure I can take that will allow me to bypass the error?
My colleague Paulina has already created an issue in our issue tracker. We haven't received any update from the team. I will send a reminder to my team now.
Unfortunately I experience this error whichever slice I try to render in the slice simulator. I've tried altering the mock data in the way described, but it hasn't cleared the error unfortunately.
I experience this error regardless as to which slice I try to render in the slice preview, and the error is still present when I comment out everything in the slice template file and simply return <p>TEST</p>.