File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
components/TooltipController Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,14 @@ const TooltipController = ({
168168 setTooltipPositionStrategy ( positionStrategy )
169169 } , [ positionStrategy ] )
170170
171+ useEffect ( ( ) => {
172+ if ( typeof window !== 'undefined' ) {
173+ // here we can do validations related to the props before inject the styles,
174+ // we can also send something into the 'detail' to the inject style function
175+ window . dispatchEvent ( new CustomEvent ( 'rt_inject_styles' , { detail : { } } ) )
176+ }
177+ } , [ ] )
178+
171179 useEffect ( ( ) => {
172180 const elementRefs = new Set ( anchorRefs )
173181
Original file line number Diff line number Diff line change @@ -20,8 +20,12 @@ import type { ITooltipWrapper } from './components/TooltipProvider/TooltipProvid
2020const TooltipCoreStyles = 'react-tooltip-core-css-placeholder'
2121const TooltipStyles = 'react-tooltip-css-placeholder'
2222
23- injectStyle ( { css : TooltipCoreStyles , type : 'core' } )
24- injectStyle ( { css : TooltipStyles } )
23+ if ( typeof window !== 'undefined' ) {
24+ window . addEventListener ( 'rt_inject_styles' , ( ) => {
25+ injectStyle ( { css : TooltipCoreStyles , type : 'core' } )
26+ injectStyle ( { css : TooltipStyles } )
27+ } )
28+ }
2529
2630export { TooltipController as Tooltip } from './components/TooltipController'
2731export { TooltipProvider , TooltipWrapper } from './components/TooltipProvider'
You can’t perform that action at this time.
0 commit comments