We are using Sitecore-10.3/Headless/SXA/NextJS. When we build a custom new component with few custom variants, we receive errors. We will not receive this when we use the "Default variant".
Steps to reproduce
- Create a new headless component(rendering)
- Add a rendering variant example "CustomVariant", other than the "Default" variant
- Go to experience editor and assemble this component on the page.
- Change the variant to "CustomVariant"
- Save the page, Immediately you will receive an error in the experience editor as like below,
Connection to your rendering host failed with an Internal Server Error error. Ensure the POST endpoint at URL http://localhost:3000/api/editing/render has been enabled. 6. Go to the NextJS application and check the same page.
Error:
Server error
TypeError: Cannot read properties of undefined (reading 'CustomVariant')
Source
src\temp\componentFactory.ts (90:21) @ exportName
88 | 89 | if (exportName && exportName !== DEFAULT_EXPORT_NAME) { 90 | return component[exportName]; | ^ 91 | } 92 | 93 | return component?.Default || component?.default || component;
NA
This issue is not happening when you assign the "Default" variant to the component.