Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: After kills the app, the cleanup function in useEffect does not execute? #27682

Closed
jianxiansining opened this issue Nov 10, 2023 · 4 comments
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@jianxiansining
Copy link

After kills the app, the cleanup function in useEffect does not execute?

@jianxiansining jianxiansining added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Nov 10, 2023
@Jyotiprakash-Redapple
Copy link

Jyotiprakash-Redapple commented Nov 10, 2023

import React from 'react'
export default function App(){

  React.useEffect(()=>{

    // execute when component insert into dom 
    return ()=>{
      // componet when destory to dom
    }
  },[
  //  componentdidUpdate
  ])
  return <>App</>
}
  • on this way you write it is execute all of life cycle

@jianxiansining
Copy link
Author

import React from 'react'
export default function App(){

  React.useEffect(()=>{

    // execute when component insert into dom 
    return ()=>{
      // componet when destory to dom
    }
  },[
  //  componentdidUpdate
  ])
  return <>App</>
}
  • on this way you write it is execute all of life cycle

useEffect(()=>{
console.log('join。。。。。。');
return()=>{
console.log('exit。。。。。。');
}
})
When killing an app, 'exit...' This log still cannot be printed

Currently: If the first page after opening the app is A, click on a method on page A to jump to page B.
Scenario 1: Click to return to page A, where the cleaning function will be executed.
Scenario 2: Force the app to be killed, and the cleaning function on page B will not be executed.
I tested that it is feasible in the lower version of React, but not in the latest version.

Copy link

github-actions bot commented Apr 5, 2024

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 5, 2024
Copy link

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants