mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-30 05:23:53 +03:00
b80cc9e5b9
* Merge react-json-tree from alexkuz/react-json-tree * Npm package config * Add credits * Stick `eslint-plugin-react` to `7.4.0` till change deprecated `componentWillReceiveProps`
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import JSONArrow from './JSONArrow';
|
|
|
|
export default class ItemRange extends React.Component {
|
|
static propTypes = {
|
|
styling: PropTypes.func.isRequired,
|
|
from: PropTypes.number.isRequired,
|
|
to: PropTypes.number.isRequired,
|
|
renderChildNodes: PropTypes.func.isRequired,
|
|
nodeType: PropTypes.string.isRequired
|
|
};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { expanded: false };
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
}
|
|
|
|
render() {
|
|
const { styling, from, to, renderChildNodes, nodeType } = this.props;
|
|
|
|
return this.state.expanded ? (
|
|
<div {...styling('itemRange', this.state.expanded)}>
|
|
{renderChildNodes(this.props, from, to)}
|
|
</div>
|
|
) : (
|
|
<div
|
|
{...styling('itemRange', this.state.expanded)}
|
|
onClick={this.handleClick}
|
|
>
|
|
<JSONArrow
|
|
nodeType={nodeType}
|
|
styling={styling}
|
|
expanded={false}
|
|
onClick={this.handleClick}
|
|
arrowStyle="double"
|
|
/>
|
|
{`${from} ... ${to}`}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
handleClick() {
|
|
this.setState({ expanded: !this.state.expanded });
|
|
}
|
|
}
|