mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-10-10 13:56:34 +03:00
* chore(deps): update typescript-eslint monorepo to v8 * instrument * react-base16-styling * Disable react/prop-types * react-json-tree * redux-devtools-ui * inspector-monitor * react-dock * log-monitor * map2tree * d3-state-visualizer * test-tab * rtk-query-monitor * slider-monitor * trace-tab * chart-monitor * app-core * utils * test-tab-demo * inspector-monitor-demo * redux-devtools-counter-demo * redux-devtools-todomvc-demo * remote * cli * react-dock-demo --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <nbierema@gmail.com>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import React, { Component, createRef } from 'react';
|
|
import { tree } from 'd3-state-visualizer';
|
|
import type { Options } from 'd3-state-visualizer';
|
|
import { base16Themes } from 'react-base16-styling';
|
|
import type { Base16Theme } from 'react-base16-styling';
|
|
import { Action, Dispatch } from 'redux';
|
|
import { LiftedAction, LiftedState } from '@redux-devtools/core';
|
|
import { ChartMonitorState } from './reducers';
|
|
|
|
const wrapperStyle = {
|
|
width: '100%',
|
|
height: '100%',
|
|
};
|
|
|
|
export interface Props<S, A extends Action<string>>
|
|
extends LiftedState<S, A, ChartMonitorState>,
|
|
Options {
|
|
dispatch: Dispatch<LiftedAction<S, A, ChartMonitorState>>;
|
|
preserveScrollTop: boolean;
|
|
select: (state: S) => unknown;
|
|
theme: keyof typeof base16Themes | Base16Theme;
|
|
invertTheme: boolean;
|
|
|
|
state: S | null;
|
|
defaultIsVisible?: boolean;
|
|
}
|
|
|
|
class Chart<S, A extends Action<string>> extends Component<Props<S, A>> {
|
|
divRef = createRef<HTMLDivElement>();
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
renderChart?: (state?: {} | null | undefined) => void;
|
|
|
|
componentDidMount() {
|
|
const { select, state, defaultIsVisible } = this.props;
|
|
this.renderChart = tree(this.divRef.current!, this.props);
|
|
if (defaultIsVisible) {
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
this.renderChart(select(state!) as {} | null | undefined);
|
|
}
|
|
}
|
|
|
|
UNSAFE_componentWillReceiveProps(nextProps: Props<S, A>) {
|
|
const { state, select, monitorState } = nextProps;
|
|
|
|
if (monitorState.isVisible !== false) {
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
this.renderChart!(select(state!) as {} | null | undefined);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return <div style={wrapperStyle} ref={this.divRef} />;
|
|
}
|
|
}
|
|
|
|
export default Chart;
|