Skip to content

Commit bde4eb1

Browse files
committed
fix(core): remove debug code that runs in production builds
- Wrap window.props assignment in debug.jsx with NODE_ENV check so it only executes in development builds - Remove debug console.log from ExamplesSelect default onSelect prop (marked with FIXME: remove before merging to master) - Remove debug console.log from ExamplesSelectValueRetainer default onSelect and updateValue props - Replace debug callbacks with no-op functions Fixes #10521
1 parent 3608eaa commit bde4eb1

3 files changed

Lines changed: 6 additions & 20 deletions

File tree

src/core/components/debug.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export default class Debug extends React.Component {
2323

2424
let { getState, getComponent } = this.props
2525

26-
window.props = this.props
26+
if (process.env.NODE_ENV === "development") {
27+
window.props = this.props
28+
}
2729

2830
const Collapse = getComponent("Collapse")
2931

src/core/components/examples-select-value-retainer.jsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,8 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
5252
setRetainRequestBodyValueFlag: () => {
5353
// NOOP
5454
},
55-
onSelect: (...args) =>
56-
// eslint-disable-next-line no-console
57-
console.log(
58-
"ExamplesSelectValueRetainer: no `onSelect` function was provided",
59-
...args
60-
),
61-
updateValue: (...args) =>
62-
// eslint-disable-next-line no-console
63-
console.log(
64-
"ExamplesSelectValueRetainer: no `updateValue` function was provided",
65-
...args
66-
),
55+
onSelect: () => {},
56+
updateValue: () => {},
6757
}
6858

6959
constructor(props) {

src/core/components/examples-select.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ export default class ExamplesSelect extends React.PureComponent {
1919

2020
static defaultProps = {
2121
examples: Map({}),
22-
onSelect: (...args) =>
23-
// eslint-disable-next-line no-console
24-
console.log(
25-
// FIXME: remove before merging to master...
26-
`DEBUG: ExamplesSelect was not given an onSelect callback`,
27-
...args
28-
),
22+
onSelect: () => {},
2923
currentExampleKey: null,
3024
showLabels: true,
3125
}

0 commit comments

Comments
 (0)