babel-plugin-transform-dev-warning
babel-plugin-transform-dev-warning copied to clipboard
React.warn/error
https://github.com/facebook/react/pull/15170 https://twitter.com/brian_d_vaughn/status/1108788282966433792
@diegohaz Thank you for opening this issue. I'm happy to see these two new helpers in React core. I'm not sure how we should handle them.
I'm not sure too. I guess I'll just update my warning function implementation to use React.warn instead of console.warn when it gets released, so this package is still useful as it is.
We will have to write a branch statement with React.warn, the overhead of adding an extra !== production condition is small. Maybe we should deprecate this babel plugin 🤔.
In Material-UI, we tend to use a custom propType as much as possible for the warning. For instance:
/**
* If `true`, the shrink animation is disabled.
* This only works if variant is `indeterminate`.
*/
disableShrink: chainPropTypes(PropTypes.bool, props => {
if (props.disableShrink && props.variant !== 'indeterminate') {
return new Error(
'Material-UI: you have provided the `disableShrink` property ' +
'with a variant other than `indeterminate`. This will have no effect.',
);
}
return null;
}),