File tree 2 files changed +32
-7
lines changed
2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,30 @@ function App() {
177
177
afterHide = { ( ) => console . log ( 'After hide' ) }
178
178
content = "Showing tooltip and calling afterShow method"
179
179
/>
180
+
181
+ < button id = "buttonCallbacksClick" > With click event</ button >
182
+ < Tooltip
183
+ events = { [ 'click' ] }
184
+ place = "bottom"
185
+ anchorId = "buttonCallbacksClick"
186
+ // eslint-disable-next-line no-console
187
+ afterShow = { ( ) => console . log ( 'After show with click' ) }
188
+ // eslint-disable-next-line no-console
189
+ afterHide = { ( ) => console . log ( 'After hide with click' ) }
190
+ content = "Showing tooltip and calling afterShow method"
191
+ />
192
+
193
+ < button id = "buttonCallbacksDelay" > With delay</ button >
194
+ < Tooltip
195
+ delayShow = { 1000 }
196
+ place = "bottom"
197
+ anchorId = "buttonCallbacksDelay"
198
+ // eslint-disable-next-line no-console
199
+ afterShow = { ( ) => console . log ( 'After show with delay' ) }
200
+ // eslint-disable-next-line no-console
201
+ afterHide = { ( ) => console . log ( 'After hide with delay' ) }
202
+ content = "Showing tooltip and calling afterShow method"
203
+ />
180
204
</ div >
181
205
</ main >
182
206
)
Original file line number Diff line number Diff line change @@ -54,15 +54,16 @@ const Tooltip = ({
54
54
} else if ( isOpen === undefined ) {
55
55
setShow ( value )
56
56
}
57
+ }
57
58
58
- // Callbacks
59
- if ( value === true && afterShow ) {
60
- afterShow ( )
61
- }
62
- if ( value === false && afterHide ) {
63
- afterHide ( )
59
+ // Callbacks
60
+ useEffect ( ( ) => {
61
+ if ( show ) {
62
+ afterShow ?. ( )
63
+ } else {
64
+ afterHide ?. ( )
64
65
}
65
- }
66
+ } , [ show ] )
66
67
67
68
const handleShowTooltipDelayed = ( ) => {
68
69
if ( tooltipShowDelayTimerRef . current ) {
You can’t perform that action at this time.
0 commit comments