Skip to content

Commit 45f890b

Browse files
committed
Add placeholders to clarify between empty string, null, and undefined
1 parent 60b0260 commit 45f890b

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

shells/dev/app/InspectableElements/Contexts.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const contextData = {
1313
object: { outer: { inner: {} } },
1414
string: 'abc',
1515
symbol: Symbol.for('symbol'),
16+
null: null,
17+
undefined: undefined,
1618
};
1719

1820
class LegacyContextProvider extends Component<any> {
@@ -24,6 +26,8 @@ class LegacyContextProvider extends Component<any> {
2426
object: PropTypes.object,
2527
string: PropTypes.string,
2628
symbol: PropTypes.symbol,
29+
null: PropTypes.any,
30+
undefined: PropTypes.any,
2731
};
2832

2933
getChildContext() {
@@ -44,6 +48,8 @@ class LegacyContextConsumer extends Component<any> {
4448
object: PropTypes.object,
4549
string: PropTypes.string,
4650
symbol: PropTypes.symbol,
51+
null: PropTypes.any,
52+
undefined: PropTypes.any,
4753
};
4854

4955
render() {

shells/dev/app/InspectableElements/NestedProps.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
import React from 'react';
44

5+
const object = {
6+
string: 'abc',
7+
longString: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKJLMNOPQRSTUVWXYZ1234567890',
8+
emptyString: '',
9+
number: 123,
10+
boolean: true,
11+
undefined: undefined,
12+
null: null,
13+
};
14+
515
export default function ObjectProps() {
616
return (
717
<ChildComponent
818
object={{
919
outer: {
10-
inner: {
11-
string: 'abc',
12-
number: 123,
13-
boolean: true,
14-
},
20+
inner: object,
1521
},
1622
}}
1723
array={['first', 'second', 'third']}
18-
objectInArray={[
19-
{
20-
string: 'abc',
21-
number: 123,
22-
boolean: true,
23-
},
24-
]}
24+
objectInArray={[object]}
2525
arrayInObject={{ array: ['first', 'second', 'third'] }}
2626
/>
2727
);

src/devtools/views/EditableValue.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ export default function EditableValue({
8686
inputValue = editableValue == null ? '' : editableValue;
8787
}
8888

89+
let placeholder = '';
90+
if (value === null) {
91+
placeholder = '(null)';
92+
} else if (value === undefined) {
93+
placeholder = '(undefined)';
94+
} else if (dataType === 'string') {
95+
placeholder = '(string)';
96+
}
97+
8998
return (
9099
<Fragment>
91100
{dataType === 'boolean' && (
@@ -105,6 +114,7 @@ export default function EditableValue({
105114
className={styles.Input}
106115
onChange={handleChange}
107116
onKeyDown={handleKeyDown}
117+
placeholder={placeholder}
108118
ref={inputRef}
109119
type={type}
110120
value={inputValue}

0 commit comments

Comments
 (0)