File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ const copilot = ({
7878
7979 startTries = 0 ;
8080
81+ mounted = false ;
82+
8183 eventEmitter = mitt ( ) ;
8284
8385 isFirstStep = ( ) : boolean => this . state . currentStep === this . getFirstStep ( ) ;
@@ -94,6 +96,9 @@ const copilot = ({
9496 }
9597
9698 unregisterStep = ( stepName : string ) : void => {
99+ if ( ! this . mounted ) {
100+ return ;
101+ }
97102 this . setState ( ( { steps } ) => ( {
98103 steps : Object . entries ( steps )
99104 . filter ( ( [ key ] ) => key !== stepName )
@@ -149,6 +154,15 @@ const copilot = ({
149154 } ) ;
150155 }
151156
157+ componentDidMount ( ) {
158+ this . mounted = true ;
159+ }
160+
161+ componentWillUnmount ( ) {
162+ console . log ( 'componentWillUnmount method' )
163+ this . mounted = false ;
164+ } ;
165+
152166 render ( ) {
153167 return (
154168 < View style = { { flex : 1 } } >
You can’t perform that action at this time.
0 commit comments