File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
react-migration-toolkit/src/react/contexts Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 1- import { createContext , type ReactNode , type PropsWithChildren } from 'react' ;
1+ import {
2+ createContext ,
3+ type ReactNode ,
4+ type PropsWithChildren ,
5+ useState ,
6+ useEffect ,
7+ } from 'react' ;
8+ import {
9+ createContext ,
10+ type ReactNode ,
11+ type PropsWithChildren ,
12+ useState ,
13+ useEffect ,
14+ } from 'react' ;
215import type ApplicationInstance from '@ember/application/instance' ;
316
417interface ApplicationProviderProps extends PropsWithChildren {
@@ -13,6 +26,20 @@ export function ApplicationProvider({
1326 owner,
1427 children,
1528} : ApplicationProviderProps ) : ReactNode {
29+ const [ isDestroyed , setIsDestroyed ] = useState < boolean > ( false ) ;
30+
31+ useEffect ( ( ) => {
32+ const oldWillDestroy = owner . willDestroy ;
33+ owner . willDestroy = ( ...args ) => {
34+ setIsDestroyed ( true ) ;
35+ oldWillDestroy . apply ( owner , args ) ;
36+ } ;
37+ } , [ owner ] ) ;
38+
39+ if ( isDestroyed ) {
40+ return null ;
41+ }
42+
1643 return (
1744 < ApplicationContext . Provider value = { owner } >
1845 { children }
You can’t perform that action at this time.
0 commit comments