File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import { createContext , useContext } from 'react' ;
22import { TooltipProps } from '@rmwc/tooltip' ;
33import dynamic from 'next/dynamic' ;
44import useTranslation from 'next-translate/useTranslation' ;
55
6- const Tooltip = dynamic < TooltipProps > ( ( ) =>
7- import ( '@rmwc/tooltip' ) . then ( ( m ) => m . Tooltip )
6+ // Temporary workaround for not being able to access the `children` prop in the
7+ // fallback loading component (while the `Tooltip` is being dynamically loaded).
8+ // @see {@link https://github.com/vercel/next.js/issues/7906 }
9+ const TooltipLoadingContext = createContext < JSX . Element > ( < > </ > ) ;
10+
11+ const Tooltip = dynamic < TooltipProps > (
12+ ( ) => import ( '@rmwc/tooltip' ) . then ( ( m ) => m . Tooltip ) ,
13+ { loading : ( ) => useContext ( TooltipLoadingContext ) }
814) ;
915
1016interface SelectHintProps {
@@ -18,8 +24,10 @@ export default function SelectHint({
1824} : SelectHintProps ) : JSX . Element {
1925 const { t } = useTranslation ( ) ;
2026 return (
21- < Tooltip content = { t ( 'common:shift-click' ) } align = 'topRight' open = { open } >
22- { children }
23- </ Tooltip >
27+ < TooltipLoadingContext . Provider value = { children } >
28+ < Tooltip content = { t ( 'common:shift-click' ) } align = 'topRight' open = { open } >
29+ { children }
30+ </ Tooltip >
31+ </ TooltipLoadingContext . Provider >
2432 ) ;
2533}
You can’t perform that action at this time.
0 commit comments