Skip to content

Commit

Permalink
[NextJs][Regression] Custom Components cannot be added using Horizon (#…
Browse files Browse the repository at this point in the history
…807)

* Fix update-graphql-fragment-data react sample

* Add optional chaining to fields of scaffolded components

* Revert "Fix update-graphql-fragment-data react sample"

This reverts commit 467600f.

* Refactor component-src template to use withDatasourceCheck()

(cherry picked from commit 7af070e)
  • Loading branch information
CobyPear authored and ambrauer committed Sep 8, 2021
1 parent fa79895 commit d9642fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/nextjs/scripts/templates/component-src.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @returns component src boilerplate as a string
*/
function generateComponentSrc(componentName: string): string {
return `import { Text, Field } from '@sitecore-jss/sitecore-jss-nextjs';
return `import { Text, Field, withDatasourceCheck } from '@sitecore-jss/sitecore-jss-nextjs';
import { StyleguideComponentProps } from 'lib/component-props';
type ${componentName}Props = StyleguideComponentProps & {
Expand All @@ -20,7 +20,7 @@ const ${componentName} = (props: ${componentName}Props): JSX.Element => (
</div>
);
export default ${componentName};
export default withDatasourceCheck()<${componentName}Props>(${componentName});
`;
}

Expand Down

0 comments on commit d9642fc

Please sign in to comment.