Skip to content

Commit

Permalink
Fixes #1986 and allows for the theme argument to be null for the Word…
Browse files Browse the repository at this point in the history
…PressBlocksProvider
  • Loading branch information
colinmurphy committed Dec 20, 2024
1 parent 6cf7643 commit fb7f89c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/blocks/src/components/WordPressBlocksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ export function WordPressBlocksProvider(props: {
* ```
*/
export function useBlocksTheme(): BlocksTheme {
const themeContext = React.useContext(WordPressThemeContext);

// If it's an empty object, the provider hasn't been initialized.
if (themeContext === undefined) {
if (WordPressBlocksContext == null || WordPressThemeContext == null) {
throw new Error(
'useBlocksTheme hook was called outside of context, make sure your app is wrapped with WordPressBlocksProvider',
);
}

return themeContext;
return React.useContext(WordPressThemeContext);;
}

0 comments on commit fb7f89c

Please sign in to comment.