File tree Expand file tree Collapse file tree
packages/react/src/routing Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,12 +24,21 @@ export class PageManager extends React.PureComponent<PageManagerProps> {
2424 // React refs must be stable (not created inline).
2525 // Wrap merged refs to add ion-page-invisible synchronously when element is created
2626 const baseMergedRefs = mergeRefs ( this . ionPageElementRef , this . props . forwardedRef ) ;
27+ // Guard against React 19 strict mode double-mount re-adding ion-page-invisible.
28+ // The ref fires again on remount after StackManager may have already removed it.
29+ let hasAppliedInvisible = false ;
2730 this . stableMergedRefs = ( node : HTMLDivElement | null ) => {
28- if ( node && ! node . classList . contains ( 'ion-page-invisible' ) && ! node . classList . contains ( 'ion-page-hidden' ) ) {
31+ if (
32+ node &&
33+ ! hasAppliedInvisible &&
34+ ! node . classList . contains ( 'ion-page-invisible' ) &&
35+ ! node . classList . contains ( 'ion-page-hidden' )
36+ ) {
2937 // Add ion-page-invisible synchronously before first paint (if in an outlet)
3038 // This prevents the flash that occurs when componentDidMount runs after paint
3139 if ( this . context ?. isInOutlet ?.( ) ) {
3240 node . classList . add ( 'ion-page-invisible' ) ;
41+ hasAppliedInvisible = true ;
3342 }
3443 }
3544 baseMergedRefs ( node ) ;
You can’t perform that action at this time.
0 commit comments