mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-23 06:29:51 +03:00
Replaced componentWillreceiveProps with getDerivedStateFromProps
This commit is contained in:
parent
d49535da03
commit
0ae52223dc
|
@ -145,11 +145,12 @@ export default class JSONNestedNode extends React.Component<Props, State> {
|
||||||
this.state = getStateFromProps(props);
|
this.state = getStateFromProps(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
static getDerivedStateFromProps(nextProps: Props, state: State): State | null {
|
||||||
const nextState = getStateFromProps(nextProps);
|
const nextState = getStateFromProps(nextProps);
|
||||||
if (getStateFromProps(this.props).expanded !== nextState.expanded) {
|
if (nextState.expanded !== state.expanded) {
|
||||||
this.setState(nextState);
|
return nextState;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Props, nextState: State) {
|
shouldComponentUpdate(nextProps: Props, nextState: State) {
|
||||||
|
|
|
@ -16,13 +16,15 @@ import {
|
||||||
} from 'react-base16-styling';
|
} from 'react-base16-styling';
|
||||||
import { CircularPropsPassedThroughJSONTree } from './types';
|
import { CircularPropsPassedThroughJSONTree } from './types';
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONTree {
|
interface ThemesConf {
|
||||||
data: any;
|
|
||||||
theme?: Theme;
|
theme?: Theme;
|
||||||
invertTheme: boolean;
|
invertTheme?: boolean;
|
||||||
|
}
|
||||||
|
interface Props extends CircularPropsPassedThroughJSONTree, ThemesConf {
|
||||||
|
data: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State extends ThemesConf {
|
||||||
styling: StylingFunction;
|
styling: StylingFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,14 +135,16 @@ export default class JSONTree extends React.Component<Props, State> {
|
||||||
this.state = getStateFromProps(props);
|
this.state = getStateFromProps(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
static getDerivedStateFromProps(nextProps: Props, state: State): State | null {
|
||||||
if (
|
if (
|
||||||
['theme', 'invertTheme'].find(
|
['theme', 'invertTheme'].find(
|
||||||
(k) => nextProps[k as keyof Props] !== this.props[k as keyof Props]
|
(k) => nextProps[k as keyof ThemesConf] !== state[k as keyof ThemesConf]
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.setState(getStateFromProps(nextProps));
|
return getStateFromProps(nextProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Props) {
|
shouldComponentUpdate(nextProps: Props) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user