diff --git a/packages/blocks/src/components/WordPressBlocksProvider.tsx b/packages/blocks/src/components/WordPressBlocksProvider.tsx index 44c869c31..84546a9f6 100644 --- a/packages/blocks/src/components/WordPressBlocksProvider.tsx +++ b/packages/blocks/src/components/WordPressBlocksProvider.tsx @@ -48,7 +48,7 @@ export function WordPressBlocksProvider(props: { config: WordPressBlocksProviderConfig; }) { const { children, config } = props; - const { blocks, theme } = config; + const { blocks, theme = {} } = config; return ( diff --git a/packages/blocks/tests/components/WordPressBlocksProvider.test.tsx b/packages/blocks/tests/components/WordPressBlocksProvider.test.tsx index e8babe9af..0ce3e7f10 100644 --- a/packages/blocks/tests/components/WordPressBlocksProvider.test.tsx +++ b/packages/blocks/tests/components/WordPressBlocksProvider.test.tsx @@ -11,13 +11,6 @@ import type { BlocksTheme } from '../../src/types/theme'; import { renderHook } from '@testing-library/react'; // Import from @testing-library/react describe('useBlocksTheme', () => { - it('Throws an error if not used within WordPressBlocksProvider', () => { - // Assert that renderHook throws an error when used outside of WordPressBlocksProvider - expect(() => { - renderHook(() => useBlocksTheme()); - }).toThrow('useBlocksTheme hook was called outside of context, make sure your app is wrapped with WordPressBlocksProvider'); - }); - it('returns the passed in theme from WordPressBlocksProvider', () => { // Wrapping component to provide context const wrapper = ({ children }: PropsWithChildren<{}>) => { @@ -46,4 +39,4 @@ describe('useBlocksTheme', () => { // Check the correct theme is returned expect(theme?.colors?.palette).toStrictEqual({ primary: 'black' }); }); -}); \ No newline at end of file +});