Skip to content

Commit

Permalink
clarify React.useDebugValue warning
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 22, 2020
1 parent 60304fe commit 70fbc15
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/material-ui/scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ const commonjsOptions = {
};

function onwarn(warning) {
let ignoreWarning = false;
if (
warning.code === 'UNUSED_EXTERNAL_IMPORT' &&
warning.source === 'react' &&
warning.names.filter(identifier => identifier !== 'useDebugValue').length === 0
warning.names.filter((identifier) => identifier !== 'useDebugValue').length === 0
) {
// skip
// only warn for
// import * as React from 'react'
// if (__DEV__) React.useDebugValue()
ignoreWarning = true;
}

if (!ignoreWarning) {
// React.useDebug not fully dce'd from prod bundle
// in the sense that it's still imported but unused. Downgrading
// it to a warning as a reminder to fix at some point
console.warn(warning.message);
} else {
throw Error(warning.message);
}
}
Expand Down

0 comments on commit 70fbc15

Please sign in to comment.