Describe the Bug
The application crashes with a runtime error when attempting to use withDatasourceCheck. The error occurs because the useSitecore hook is being called within a React Server Component (RSC), which does not support React Context in the sdk code
Error Message
Attempted to call useSitecore() from the server but useSitecore is on the client. It's not possible to invoke a client function from the server...
To Reproduce
Steps to Reproduce
- Create a standard component without the "withDatasourceCheck" directive.
- Import withDatasourceCheck from @sitecore-content-sdk/nextjs.
- Attempt to build or run the application.
- Observe the build-time or runtime crash.
Expected Behavior
Expected Behavior
withDatasourceCheck should be work without issue and show message if no datasource added.
Possible Fix
Proposed Fix
Refactor the code in sdk for not using const { page } = useSitecore(); instate of this use const page = props?.page;
Provide environment information
- Sitecore Version: SitecoreAI
- Content SDK Version: 1.4.0
- Operating System and version (desktop or mobile): Windows 11
Describe the Bug
The application crashes with a runtime error when attempting to use withDatasourceCheck. The error occurs because the useSitecore hook is being called within a React Server Component (RSC), which does not support React Context in the sdk code
Error Message
Attempted to call useSitecore() from the server but useSitecore is on the client. It's not possible to invoke a client function from the server...To Reproduce
Steps to Reproduce
Expected Behavior
Expected Behavior
withDatasourceCheck should be work without issue and show message if no datasource added.
Possible Fix
Proposed Fix
Refactor the code in sdk for not using
const { page } = useSitecore();instate of this useconst page = props?.page;Provide environment information