diff --git a/src/components/charts/line/LineSlicesItem.js b/src/components/charts/line/LineSlicesItem.js
index 180712cab..7b7793990 100644
--- a/src/components/charts/line/LineSlicesItem.js
+++ b/src/components/charts/line/LineSlicesItem.js
@@ -6,61 +6,68 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-import React, { PureComponent } from 'react'
+import React from 'react'
+import PropTypes from 'prop-types'
+import compose from 'recompose/compose'
+import pure from 'recompose/pure'
+import withState from 'recompose/withState'
+import withHandlers from 'recompose/withHandlers'
+import withPropsOnChange from 'recompose/withPropsOnChange'
import TableTooltip from '../../tooltip/TableTooltip'
const Chip = ({ color }) =>
-export default class LineSlicesItem extends PureComponent {
- state = {
- isHover: false,
- }
+const LineSlicesItem = ({ slice, height, showTooltip, hideTooltip, isHover }) =>
+
+ {isHover &&
+ }
+
+
- handleMouseEnter = e => {
- this.setState({ isHover: true })
-
- const { slice, showTooltip } = this.props
- showTooltip(
- [, p.id, p.value])}
- />,
- e
- )
- }
-
- handleMouseLeave = () => {
- this.setState({ isHover: false })
- this.props.hideTooltip()
- }
+LineSlicesItem.propTypes = {
+ slice: PropTypes.object.isRequired,
+ height: PropTypes.number.isRequired,
+ showTooltip: PropTypes.func.isRequired,
+ hideTooltip: PropTypes.func.isRequired,
+ isHover: PropTypes.bool.isRequired,
+}
- render() {
- const { slice, height } = this.props
- const { isHover } = this.state
+const enhance = compose(
+ withState('isHover', 'setIsHover', false),
+ withPropsOnChange(['slice'], ({ slice }) => ({
+ tooltip: (
+ [, p.id, p.value])} />
+ ),
+ })),
+ withHandlers({
+ showTooltip: ({ showTooltip, setIsHover, tooltip }) => e => {
+ setIsHover(true)
+ showTooltip(tooltip, e)
+ },
+ hideTooltip: ({ hideTooltip, setIsHover }) => () => {
+ setIsHover(false)
+ hideTooltip()
+ },
+ }),
+ pure
+)
- return (
-
- {isHover &&
- }
-
-
- )
- }
-}
+export default enhance(LineSlicesItem)