File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed
src/docs/exampleComponents/Tooltip Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -69,17 +69,17 @@ const getIntroOfPage = (label) => {
69
69
} ;
70
70
71
71
const CustomTooltip = ( { active, payload, label } ) => {
72
- if ( active && payload && payload . length ) {
73
- return (
74
- < div className = "custom-tooltip" >
75
- < p className = "label" > { ` ${ label } : ${ payload [ 0 ] . value } ` } </ p >
76
- < p className = "intro" > { getIntroOfPage ( label ) } </ p >
77
- < p className = "desc" > Anything you want can be displayed here. </ p >
78
- </ div >
79
- ) ;
80
- }
81
-
82
- return null ;
72
+ const isVisible = active && payload && payload . length ;
73
+ return (
74
+ < div className = "custom-tooltip" style = { { visibility : isVisible ? 'visible' : 'hidden' } } >
75
+ { isVisible && (
76
+ < >
77
+ < p className = "label" > { ` ${ label } : ${ payload [ 0 ] . value } ` } </ p >
78
+ < p className = "intro" > { getIntroOfPage ( label ) } </ p >
79
+ < p className = "desc" > Anything you want can be displayed here. </ p > </ >
80
+ ) }
81
+ </ div >
82
+ ) ;
83
83
} ;
84
84
85
85
export default class Example extends PureComponent {
@@ -102,7 +102,7 @@ export default class Example extends PureComponent {
102
102
< CartesianGrid strokeDasharray = "3 3" />
103
103
< XAxis dataKey = "name" />
104
104
< YAxis />
105
- < Tooltip content = { < CustomTooltip /> } />
105
+ < Tooltip content = { CustomTooltip } />
106
106
< Legend />
107
107
< Bar dataKey = "pv" barSize = { 20 } fill = "#8884d8" />
108
108
</ BarChart >
You can’t perform that action at this time.
0 commit comments