@@ -54,23 +54,27 @@ function useLabel(value, type) {
5454 }
5555}
5656
57- const useTreeLabelStyles = makeStyles ( {
58- objectKey : {
59- color : 'rgb(227, 110, 236)' ,
60- } ,
61- objectValue : { } ,
62- 'type-function' : {
63- fontStyle : 'italic' ,
64- } ,
65- 'type-string' : {
66- color : 'rgb(233, 63, 59)' ,
67- } ,
68- 'type-boolean' : {
69- color : 'rgb(153, 128, 255);' ,
70- } ,
71- 'type-number' : {
72- color : 'rgb(153, 128, 255);' ,
73- } ,
57+ const useTreeLabelStyles = makeStyles ( theme => {
58+ const darkMode = theme . palette . type === 'dark' ;
59+
60+ return {
61+ objectKey : {
62+ color : darkMode ? 'rgb(227, 110, 236)' : 'rgb(136, 19, 145)' ,
63+ } ,
64+ objectValue : { } ,
65+ 'type-function' : {
66+ fontStyle : 'italic' ,
67+ } ,
68+ 'type-string' : {
69+ color : darkMode ? 'rgb(233, 63, 59)' : 'rgb(196, 26, 22)' ,
70+ } ,
71+ 'type-boolean' : {
72+ color : darkMode ? 'rgb(153, 128, 255)' : 'rgb(28, 0, 207)' ,
73+ } ,
74+ 'type-number' : {
75+ color : darkMode ? 'rgb(153, 128, 255)' : 'rgb(136, 19, 145)' ,
76+ } ,
77+ } ;
7478} ) ;
7579
7680function TreeLabel ( { objectKey, objectValue } ) {
@@ -136,13 +140,14 @@ function Inspector(props) {
136140 const defaultExpanded = React . useMemo ( ( ) => {
137141 return Array . isArray ( expandPaths )
138142 ? expandPaths . map ( expandPath => `${ keyPrefix } .${ expandPath } ` )
139- : undefined ;
143+ : [ ] ;
140144 } , [ keyPrefix , expandPaths ] ) ;
141145
142146 return (
143147 < TreeView
144148 /* expandPaths are only set on the client so we need to remount */
145- key = { defaultExpanded }
149+ /* we need "semantic equality" here since the array is returned from useMemo which does not have semantic guarantees */
150+ key = { defaultExpanded . join ( '' ) }
146151 defaultCollapseIcon = { < ExpandIcon /> }
147152 defaultExpanded = { defaultExpanded }
148153 defaultExpandIcon = { < CollapseIcon /> }
0 commit comments