diff --git a/src/hooks/useContent.ssr.test.ts b/src/hooks/useContent.ssr.test.ts index 492ae2fa..c096fe23 100644 --- a/src/hooks/useContent.ssr.test.ts +++ b/src/hooks/useContent.ssr.test.ts @@ -18,6 +18,6 @@ describe('useContent (SSR)', () => { it('should require an initial value for server-side rending', () => { expect(() => useContent('slot-id')) - .toThrow(new Error('The initial value is required for server-side rendering (SSR).')); + .toThrow('The initial content is required for server-side rendering (SSR).'); }); }); diff --git a/src/hooks/useContent.ts b/src/hooks/useContent.ts index a7da67e5..fce1b5e6 100644 --- a/src/hooks/useContent.ts +++ b/src/hooks/useContent.ts @@ -33,7 +33,10 @@ function useSsrContent( {initial}: UseContentOptions = {}, ): SlotContent | I | F { if (initial === undefined) { - throw new Error('The initial value is required for server-side rendering (SSR).'); + throw new Error( + 'The initial content is required for server-side rendering (SSR). ' + + 'For help, see https://croct.help/sdk/react/missing-initial-slot-content', + ); } return initial; diff --git a/src/hooks/useCroct.test.tsx b/src/hooks/useCroct.test.tsx index 9529f9a3..f1ebfbb3 100644 --- a/src/hooks/useCroct.test.tsx +++ b/src/hooks/useCroct.test.tsx @@ -8,7 +8,7 @@ describe('useCroct', () => { jest.spyOn(console, 'error').mockImplementation(); expect(() => renderHook(() => useCroct())) - .toThrow(new Error('useCroct() can only be used in the context of a component.')); + .toThrow('useCroct() can only be used in the context of a component.'); // eslint-disable-next-line no-console -- Testing console output. expect(console.error).toHaveBeenCalled(); diff --git a/src/hooks/useCroct.ts b/src/hooks/useCroct.ts index 144f54d0..b456a65c 100644 --- a/src/hooks/useCroct.ts +++ b/src/hooks/useCroct.ts @@ -6,7 +6,10 @@ export function useCroct(): Plug { const context = useContext(CroctContext); if (context === null) { - throw new Error('useCroct() can only be used in the context of a component.'); + throw new Error( + 'useCroct() can only be used in the context of a component. ' + + 'For help, see https://croct.help/sdk/react/missing-provider', + ); } return context.plug; diff --git a/src/hooks/useEvaluation.ssr.test.ts b/src/hooks/useEvaluation.ssr.test.ts index 6d993430..ffe9dc87 100644 --- a/src/hooks/useEvaluation.ssr.test.ts +++ b/src/hooks/useEvaluation.ssr.test.ts @@ -18,6 +18,6 @@ describe('useEvaluation (SSR)', () => { it('should require an initial value for server-side rending', () => { expect(() => useEvaluation('location')) - .toThrow(new Error('The initial value is required for server-side rendering (SSR).')); + .toThrow('The initial value is required for server-side rendering (SSR).'); }); }); diff --git a/src/hooks/useEvaluation.ts b/src/hooks/useEvaluation.ts index 43383132..382e8bb5 100644 --- a/src/hooks/useEvaluation.ts +++ b/src/hooks/useEvaluation.ts @@ -49,7 +49,10 @@ function useSsrEvaluation( {initial}: UseEvaluationOptions = {}, ): T | I | F { if (initial === undefined) { - throw new Error('The initial value is required for server-side rendering (SSR).'); + throw new Error( + 'The initial value is required for server-side rendering (SSR). ' + + 'For help, see https://croct.help/sdk/react/missing-initial-evaluation-value', + ); } return initial; diff --git a/src/ssr-polyfills.ts b/src/ssr-polyfills.ts index f1e468b3..0c47ec7b 100644 --- a/src/ssr-polyfills.ts +++ b/src/ssr-polyfills.ts @@ -62,7 +62,8 @@ export const croct: Plug = !isSsr() throw new Error( `Property croct.${String(property)} is not supported on server-side (SSR). ` + 'Consider refactoring the logic as a side-effect (useEffect) or a client-side callback ' - + '(onClick, onChange, etc).', + + '(onClick, onChange, etc). ' + + 'For help, see https://croct.help/sdk/react/client-side-methods', ); } },