Skip to content

Commit

Permalink
Fixed logic
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmurphy committed Dec 20, 2024
1 parent 24f4d0e commit 54cfbaf
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/blocks/src/components/WordPressBlocksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,20 @@ export function WordPressBlocksProvider(props: {
* const theme = useBlocksTheme();
* ```
*/
export function useBlocksTheme(): BlocksTheme | null {
export function useBlocksTheme(): BlocksTheme {

Check failure on line 72 in packages/blocks/src/components/WordPressBlocksProvider.tsx

View workflow job for this annotation

GitHub Actions / lint_packages

Delete `⏎`
// If it's an empty object, the provider hasn't been initialized.±
if (typeof WordPressBlocksContext === 'undefined') {
if (typeof WordPressBlocksContext === 'undefined' || typeof WordPressBlocksContext === 'undefined') {

Check failure on line 74 in packages/blocks/src/components/WordPressBlocksProvider.tsx

View workflow job for this annotation

GitHub Actions / lint_packages

Replace `↹if·(typeof·WordPressBlocksContext·===·'undefined'·||·typeof·WordPressBlocksContext·===·'undefined'` with `··if·(⏎····typeof·WordPressBlocksContext·===·'undefined'·||⏎····typeof·WordPressBlocksContext·===·'undefined'⏎··`
throw new Error(

Check failure on line 75 in packages/blocks/src/components/WordPressBlocksProvider.tsx

View workflow job for this annotation

GitHub Actions / lint_packages

Replace `↹↹` with `····`
'useBlocksTheme hook was called outside of context, make sure your app is wrapped with WordPressBlocksProvider',
);
}

Check failure on line 78 in packages/blocks/src/components/WordPressBlocksProvider.tsx

View workflow job for this annotation

GitHub Actions / lint_packages

Replace `↹` with `··`

// Theme is optional
if (typeof WordPressBlocksContext === 'undefined' || WordPressBlocksContext === null) {
return null;
}

const themeContext = React.useContext(WordPressThemeContext);
if (typeof themeContext === 'undefined' || themeContext === null) {
return null;
if (typeof themeContext === 'undefined') {

Check failure on line 81 in packages/blocks/src/components/WordPressBlocksProvider.tsx

View workflow job for this annotation

GitHub Actions / lint_packages

Replace `↹` with `··`
throw new Error(

Check failure on line 82 in packages/blocks/src/components/WordPressBlocksProvider.tsx

View workflow job for this annotation

GitHub Actions / lint_packages

Replace `↹↹` with `····`
'useBlocksTheme hook was called outside of context, make sure your app is wrapped with WordPressBlocksProvider',
);
}

return themeContext;
Expand Down

0 comments on commit 54cfbaf

Please sign in to comment.