File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,9 @@ const plugin: JupyterFrontEndPlugin<void> = {
168168} ;
169169
170170function Artwork ( props : { dataRef : React . Ref < WebDataGrid > } ) : JSX . Element {
171- const tooltipAnchor = React . useRef < HTMLElement > ( null ) ;
171+ const [ tooltipAnchor , setTooltipAnchor ] = React . useState < HTMLElement | null > (
172+ null
173+ ) ;
172174
173175 const onEvent = ( event : any ) => {
174176 console . log ( event ) ;
@@ -275,9 +277,15 @@ function Artwork(props: { dataRef: React.Ref<WebDataGrid> }): JSX.Element {
275277 </ div >
276278 < div className = "jp-FlexColumn" >
277279 < label > Tooltip</ label >
278- { /* The tooltip component needs to be placed after the anchor so the reference is defined */ }
279- < Button ref = { tooltipAnchor } > Anchor</ Button >
280- < Tooltip anchorElement = { tooltipAnchor . current } > React tooltip</ Tooltip >
280+ { /* Use callback ref to react to the component mount */ }
281+ < Button
282+ ref = { ( anchor : HTMLElement ) => {
283+ setTooltipAnchor ( anchor ) ;
284+ } }
285+ >
286+ Anchor
287+ </ Button >
288+ < Tooltip anchorElement = { tooltipAnchor } > React tooltip</ Tooltip >
281289 </ div >
282290 </ div >
283291 < div className = "jp-FlexColumn" style = { { gridColumn : 4 } } >
You can’t perform that action at this time.
0 commit comments