2

I installed the Sitecore 10.4 with Headless SXA and I noticed a strange behavior. On the components which has a "Component GraphQL Query" this field is ignored. On a 10.3 solution Link List component works fine on Experience Editor and on Next.js

On Experience editor I see:

enter image description here

On Next.js app I see the right content:

enter image description here

This is the code from the default installation for LinkList SXA component:

if (datasource) {
    const list = datasource.children.results
      .filter((element: ResultsFieldLink) => element?.field?.link)
      .map((element: ResultsFieldLink, key: number) => (
        <LinkListItem
          index={key}
          key={`${key}${element.field.link}`}
          total={datasource.children.results.length}
          field={element.field.link}
        />
      ));

    return (
      <div className={styles} id={id ? id : undefined}>
        <div className="component-content">
          <Text tag="h3" field={datasource?.field?.title} />
          <Text tag="h3" field={datasource?.field?.title2} />
          <ul>{list}</ul>
        </div>
      </div>
    );
  }

  return (
    <div className={styles} id={id ? id : undefined}>
      <div className="component-content">
        <h3>Link List</h3>
      </div>
    </div>
  );

This is the Nextjs Component definition

  export const Default = (props: LinkListProps): JSX.Element => {
  const datasource = props.fields?.data?.datasource;

and the problem looks to be datasource is null on Experience Editor which doesn't make any sense.

6
  • Are other components working in Experience Editor? Commented May 17 at 13:44
  • yes all components except the components with "Component GraphQL Query" field filled. Commented May 17 at 13:49
  • And the type declared is like this - link: LinkField; Commented May 17 at 13:55
  • it doens't matter the field type , the problem is datasource is not filled Commented May 17 at 14:12
  • Can you check the Layout service output then? Commented May 17 at 14:19

1 Answer 1

2

I installed in the solution 2 modules : Sitecore Headless Rendering 22 and Sitecore CLI latest version.

The "Sitecore CLI" module was installed as the last one. This module contains the Sitecore.Services.GraphQL.*.dll files. In the CLI, these files have the 5.2 version, which should be compatible with Sitecore 10.1, 10.2, 10.3, and 10.4 versions.

The Sitecore Headless Rendering 22 module has the 8.0 version for these DLLs, which should be compatible only with the Sitecore 10.4 version.

To fix the issue I had to installed Sitecore Headless Rendering 22 module as the last one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.