Skip to content

Commit

Permalink
[easy] Remove development mode restriction on theme provider warning …
Browse files Browse the repository at this point in the history
…logic
  • Loading branch information
clintandrewhall committed Dec 4, 2022
1 parent a0c3802 commit 059fc72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src-docs/src/views/provider/provider_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const ProviderExample = {
</p>
<p>
<EuiCode>setEuiDevProviderWarning</EuiCode> is a function that will
enable adding logging or erroring in development mode only. It
enable adding logging or erroring if the Provider is missing. It
accepts three levels:
</p>
<ul>
Expand Down
30 changes: 14 additions & 16 deletions src/services/theme/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,20 @@ export const useEuiTheme = <T extends {} = {}>(): UseEuiTheme<T> => {
const colorMode = useContext(EuiColorModeContext);
const modifications = useContext(EuiModificationsContext);

if (process.env.NODE_ENV !== 'production') {
const isFallback = theme === defaultComputedTheme;
const warningLevel = getEuiDevProviderWarning();
if (isFallback && typeof warningLevel !== 'undefined') {
switch (warningLevel) {
case 'log':
console.log(providerMessage);
break;
case 'warn':
console.warn(providerMessage);
break;
case 'error':
throw new Error(providerMessage);
default:
break;
}
const isFallback = theme === defaultComputedTheme;
const warningLevel = getEuiDevProviderWarning();
if (isFallback && typeof warningLevel !== 'undefined') {
switch (warningLevel) {
case 'log':
console.log(providerMessage);
break;
case 'warn':
console.warn(providerMessage);
break;
case 'error':
throw new Error(providerMessage);
default:
break;
}
}

Expand Down

0 comments on commit 059fc72

Please sign in to comment.