Skip to content

Commit 2f0280f

Browse files
feat(overmind-devtools-client): sort object keys alphabetically
1 parent 41c00be commit 2f0280f

File tree

1 file changed

+24
-18
lines changed
  • packages/node_modules/overmind-devtools-client/src/components/Inspector

1 file changed

+24
-18
lines changed

packages/node_modules/overmind-devtools-client/src/components/Inspector/index.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { createElement, FunctionComponent, useState, memo } from 'react'
2-
import { isObject, isArray } from './utils'
3-
import { isValidJson } from '../../overmind/utils'
4-
import * as styles from './styles'
51
import { css } from 'emotion'
6-
import { colors } from '../../theme'
2+
import { FunctionComponent, createElement, memo, useState } from 'react'
73
import { FaEdit } from 'react-icons/fa'
84

5+
import { isValidJson } from '../../overmind/utils'
6+
import { colors } from '../../theme'
7+
import * as styles from './styles'
8+
import { isArray, isObject } from './utils'
9+
910
function renderValue({
1011
path,
1112
value,
@@ -215,7 +216,10 @@ const Nested: FunctionComponent<NestedProps> = memo(
215216
<span className={styles.keyCount}>
216217
{isArray
217218
? keys.length + ' items'
218-
: keys.slice(0, 3).join(', ') + '...'}
219+
: keys
220+
.sort()
221+
.slice(0, 3)
222+
.join(', ') + '...'}
219223
</span>
220224
{endBracket}
221225
</PathTools>
@@ -257,18 +261,20 @@ const Nested: FunctionComponent<NestedProps> = memo(
257261
selectedStatePath,
258262
})
259263
)
260-
: Object.keys(value).map((key) =>
261-
renderValue({
262-
path: path.concat((path ? '.' : '') + key),
263-
value: value[key],
264-
renderPaths,
265-
expandedPaths,
266-
onClickPath,
267-
onSubmitState,
268-
onToggleExpand,
269-
selectedStatePath,
270-
})
271-
)}
264+
: Object.keys(value)
265+
.sort()
266+
.map((key) =>
267+
renderValue({
268+
path: path.concat((path ? '.' : '') + key),
269+
value: value[key],
270+
renderPaths,
271+
expandedPaths,
272+
onClickPath,
273+
onSubmitState,
274+
onToggleExpand,
275+
selectedStatePath,
276+
})
277+
)}
272278
</div>
273279
<div className={styles.bracket(false)}>{endBracket}</div>
274280
</div>

0 commit comments

Comments
 (0)