Skip to content

Commit bdb7d7f

Browse files
authored
Bug: Fixing null/undefined theme argument for the WordPressBlocksProvider (#2013)
* Fixes #1986 and allows for the theme argument to be null for the WordPressBlocksProvider * Fixed typo * Fixing lint issue if theme context is undefined. * Fixed conditions to allow null for the theme argument * Fixed logic * Fixed lint issues * Fixed typo after running eslint and it changed WordPressThemeContext * Returning theme context as this isn't required by the WordPressBlockProvider * Set return type as BlocksTheme * Removed test assertion to check if theme is undefined * Updating to use a default value for theme instead in order to prevent an undefined themeContext error to be thrown for useBlocksTheme function * Removed testing code * Reverted test deletion. * Addec changeset
1 parent adf5a6d commit bdb7d7f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/afraid-terms-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@faustwp/blocks": patch
3+
---
4+
5+
Bug: Fixed an issue an issue with WordPressBlocksProvider and the theme argument to allow it to be optional and not throw an error. By default theme is now an empty object

packages/blocks/src/components/WordPressBlocksProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function WordPressBlocksProvider(props: {
4848
config: WordPressBlocksProviderConfig;
4949
}) {
5050
const { children, config } = props;
51-
const { blocks, theme } = config;
51+
const { blocks, theme = {} } = config;
5252

5353
return (
5454
<WordPressBlocksContext.Provider value={blocks}>

0 commit comments

Comments
 (0)