Enonic version: Enonic CLI version 2.3.3 OS: MacOs 13.3.1
Topic: Using React4xp to server side render a component that is configurable by editor.
I am facing an issue where there is a variable not being defined, the variable in my case is a variable named “name”. This came up when I was adding checkboxes to the react component. There is no variable in the component that is undefined nor defined as “name” (checked this by running it outside of enonic).
The error occurs during the server side rendering process (if I do not render the checkboxes until client side rendering takes place problem is solved). However, this makes it a bit more tricky for content managers to edit the fields since it makes previewing a bit more time consuming.
Below is a small segment of the error message in the terminal, the stack trace is quite long, so I do not know which part is vital for error tracing this. So far all the config props are correct, and viewing this setting the component to be client side rendered, the issue is not present.
ScriptException: org.graalvm.polyglot.PolyglotException: ReferenceError: name is not defined
in com.enonic.lib.react4xp.ssr.ServerSideRenderer.runSSR
I understand I might not be providing very specific info regarding the issue, would be so helpful if anyone could assist on this, and if needed please ask for more context on a specific area of this matter so that I can update with more vital information, or pinpoints on where I could look to get vital error tracing ‘leads’.
So if it’s a problem outside of Enonic XP, then why shouldn’t it be a problem inside Enonic XP?
I’m not understanding your explanantion…
Have you tried writing some log.info() statements in your part controllers? What does the props sent to React look like?
Have you tried writing some console.log() statements in your React code? What does the props received look like? Are you using state variables? How do they look, etc.
I might have been unclear here, but the issue is happening when I run this react component in Enonic XP, by running this component outside of Enonic XP the issue is not present. So the issue is related to the server side rendering functionality of react4xp.
No props are undefined, no props are missing, no props is named “name”.
State variables are used by a reducer, and they don’t give any errors or incorrect values.