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
- `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.
- `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`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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