Hello, I want to add a JavaScript code to my pages with preloading. I don't encounter any issues with simple window commands. However, when I try to include a library (XState) and work with it, it doesn't work. I also tried creating a different query and testing the on-page-load option in advance mode, but that doesn't work either. When I run the entire code on a single query page, I can access the outputs without any problems. Do you have any suggestions for a solution?
const { createMachine, } = XState;
const trafficLightMachine = createMachine({
id: 'trafficLight',
initial: 'red',
states: {
red: {
on: {
NEXT: 'green'
}
},
yellow: {
on: {
NEXT: 'red'
}
},
green: {
on: {
NEXT: 'yellow'
}
}
}
});
For example, when I use the code 'return trafficLightMachine.initial' in the query screen along with the above codes, it works. However, when I move the above codes to preload, I get this message: 'message: "trafficLightMachine is not defined"'.