Update usages

This commit is contained in:
Nathan Bierema 2023-01-03 09:20:21 -05:00
parent 4c60c7d75a
commit 1de4f48200
10 changed files with 22 additions and 18 deletions

View File

@ -139,7 +139,7 @@ Their full signatures are:
#### More Options #### More Options
- `shouldExpandNode: function(keyPath, data, level)` - determines if node should be expanded (root is expanded by default) - `shouldExpandNodeInitially: function(keyPath, data, level)` - determines if node should be expanded when it first renders (root is expanded by default)
- `hideRoot: boolean` - if `true`, the root node is hidden. - `hideRoot: boolean` - if `true`, the root node is hidden.
- `sortObjectKeys: boolean | function(a, b)` - sorts object keys with compare function (optional). Isn't applied to iterable maps like `Immutable.Map`. - `sortObjectKeys: boolean | function(a, b)` - sorts object keys with compare function (optional). Isn't applied to iterable maps like `Immutable.Map`.
- `postprocessValue: function(value)` - maps `value` to a new `value` - `postprocessValue: function(value)` - maps `value` to a new `value`

View File

@ -194,7 +194,11 @@ const App = () => (
</div> </div>
<p>Collapsed root node</p> <p>Collapsed root node</p>
<div> <div>
<JSONTree data={data} theme={theme} shouldExpandNode={() => false} /> <JSONTree
data={data}
theme={theme}
shouldExpandNodeInitially={() => false}
/>
</div> </div>
</div> </div>
); );

View File

@ -104,7 +104,7 @@ export default class JSONDiff extends Component<Props, State> {
valueRenderer={this.valueRenderer} valueRenderer={this.valueRenderer}
postprocessValue={prepareDelta} postprocessValue={prepareDelta}
isCustomNode={Array.isArray} isCustomNode={Array.isArray}
shouldExpandNode={expandFirstLevel} shouldExpandNodeInitially={expandFirstLevel}
hideRoot hideRoot
/> />
); );

View File

@ -115,7 +115,7 @@ export default class LogMonitorEntry<
data={data} data={data}
invertTheme={false} invertTheme={false}
keyPath={['state']} keyPath={['state']}
shouldExpandNode={this.shouldExpandNode} shouldExpandNodeInitially={this.shouldExpandNodeInitially}
/> />
); );
} catch (err) { } catch (err) {
@ -149,7 +149,7 @@ export default class LogMonitorEntry<
} }
}; };
shouldExpandNode = ( shouldExpandNodeInitially = (
keyPath: (string | number)[], keyPath: (string | number)[],
data: any, data: any,
level: number level: number

View File

@ -42,7 +42,7 @@ export default class LogMonitorAction<
invertTheme={false} invertTheme={false}
keyPath={['action']} keyPath={['action']}
data={payload} data={payload}
shouldExpandNode={this.shouldExpandNode} shouldExpandNodeInitially={this.shouldExpandNodeInitially}
/> />
) : ( ) : (
'' ''
@ -51,7 +51,7 @@ export default class LogMonitorAction<
); );
} }
shouldExpandNode = ( shouldExpandNodeInitially = (
keyPath: (string | number)[], keyPath: (string | number)[],
data: any, data: any,
level: number level: number

View File

@ -58,7 +58,7 @@ export class QueryPreviewActions extends PureComponent<QueryPreviewActionsProps>
return false; return false;
}; };
shouldExpandNode = ( shouldExpandNodeInitially = (
keyPath: (string | number)[], keyPath: (string | number)[],
value: unknown, value: unknown,
layer: number layer: number
@ -85,7 +85,7 @@ export class QueryPreviewActions extends PureComponent<QueryPreviewActionsProps>
rootProps={rootProps} rootProps={rootProps}
data={this.selectFormattedActions(actionsOfQuery)} data={this.selectFormattedActions(actionsOfQuery)}
isWideLayout={isWideLayout} isWideLayout={isWideLayout}
shouldExpandNode={this.shouldExpandNode} shouldExpandNodeInitially={this.shouldExpandNodeInitially}
/> />
); );
} }

View File

@ -45,7 +45,7 @@ export class QueryPreviewApi extends PureComponent<QueryPreviewApiProps> {
<TreeView <TreeView
before={<h3>State</h3>} before={<h3>State</h3>}
data={apiState} data={apiState}
shouldExpandNode={this.shouldExpandApiStateNode} shouldExpandNodeInitially={this.shouldExpandApiStateNode}
isWideLayout={isWideLayout} isWideLayout={isWideLayout}
/> />
{apiStats && ( {apiStats && (

View File

@ -15,7 +15,7 @@ const rootProps: TreeViewProps['rootProps'] = {
}; };
export class QueryPreviewData extends PureComponent<QueryPreviewDataProps> { export class QueryPreviewData extends PureComponent<QueryPreviewDataProps> {
shouldExpandNode = ( shouldExpandNodeInitially = (
keyPath: (string | number)[], keyPath: (string | number)[],
value: unknown, value: unknown,
layer: number layer: number
@ -31,7 +31,7 @@ export class QueryPreviewData extends PureComponent<QueryPreviewDataProps> {
rootProps={rootProps} rootProps={rootProps}
data={data} data={data}
isWideLayout={isWideLayout} isWideLayout={isWideLayout}
shouldExpandNode={this.shouldExpandNode} shouldExpandNodeInitially={this.shouldExpandNodeInitially}
/> />
); );
} }

View File

@ -35,7 +35,7 @@ export interface QueryPreviewInfoProps {
isWideLayout: boolean; isWideLayout: boolean;
} }
export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> { export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> {
shouldExpandNode = ( shouldExpandNodeInitially = (
keyPath: (string | number)[], keyPath: (string | number)[],
value: unknown, value: unknown,
layer: number layer: number
@ -107,7 +107,7 @@ export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> {
rootProps={rootProps} rootProps={rootProps}
data={formattedQuery} data={formattedQuery}
isWideLayout={isWideLayout} isWideLayout={isWideLayout}
shouldExpandNode={this.shouldExpandNode} shouldExpandNodeInitially={this.shouldExpandNodeInitially}
/> />
); );
} }

View File

@ -14,7 +14,7 @@ export interface TreeViewProps
extends Partial< extends Partial<
Pick< Pick<
ComponentProps<typeof JSONTree>, ComponentProps<typeof JSONTree>,
'keyPath' | 'shouldExpandNode' | 'hideRoot' 'keyPath' | 'shouldExpandNodeInitially' | 'hideRoot'
> >
> { > {
data: unknown; data: unknown;
@ -30,7 +30,7 @@ export interface TreeViewProps
export class TreeView extends React.PureComponent<TreeViewProps> { export class TreeView extends React.PureComponent<TreeViewProps> {
static defaultProps = { static defaultProps = {
hideRoot: true, hideRoot: true,
shouldExpandNode: ( shouldExpandNodeInitially: (
keyPath: (string | number)[], keyPath: (string | number)[],
value: unknown, value: unknown,
layer: number layer: number
@ -81,7 +81,7 @@ export class TreeView extends React.PureComponent<TreeViewProps> {
after, after,
children, children,
keyPath, keyPath,
shouldExpandNode, shouldExpandNodeInitially,
hideRoot, hideRoot,
rootProps, rootProps,
} = this.props; } = this.props;
@ -94,7 +94,7 @@ export class TreeView extends React.PureComponent<TreeViewProps> {
{before} {before}
<JSONTree <JSONTree
keyPath={keyPath} keyPath={keyPath}
shouldExpandNode={shouldExpandNode} shouldExpandNodeInitially={shouldExpandNodeInitially}
data={data} data={data}
labelRenderer={this.selectLabelRenderer(styling)} labelRenderer={this.selectLabelRenderer(styling)}
theme={this.selectTheme(base16Theme)} theme={this.selectTheme(base16Theme)}