Comments (2)
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
from react.
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.
from react.
Related Issues (20)
- Hi @gameprivatesv!
- Bug: Modify value of textarea value in react s page by javascript and select dropdown item by javascript HOT 2
- eslint-plugin-react-hooks & "Flat Config" (ESLint 9) HOT 10
- Bug: eslint-plugin-react-hooks still links to legacy.reactjs.org HOT 2
- Bug: eslint-plugin-react-hooks `exhaustive-deps` rule shouldn't warn when using an object's property HOT 3
- [DevTools Bug]: Consistent memory leak when refreshing on React + non-React websites. HOT 16
- Bug: Adding StrictMode component leads to cases that can't happen in concurrent mode. HOT 3
- Bug: <link> onLoad event happened but not triggered (18.2.0 & 18.3.0-canary-2e470a788-20240214) HOT 1
- Introducing `UseConstantState()` - A Novel Approach to Permanent State Management 🚀 HOT 6
- Bug: `textarea` inputs in Safari stop accepting input if certain lines are deleted HOT 5
- React Project Doesn't display on browser HOT 2
- Bug: Undo/Redo not behaving as expected for controlled input when state is updated from an async callback HOT 3
- Bug: React can leak the whole subtree when using contentEditable (reproduction sscce included) HOT 2
- Request: Define to exports cjs/* files in package.json
- Feature request: Define prop preprocessor
- Bug: errors caught by error boundaries appear in console twice HOT 1
- Bug: `flushSync` does not work HOT 2
- Bug: Next.js Build Errors Fix HOT 1
- Bug: React is bullshit HOT 5
- Bug: Use useId function to generate dom id,it can't use document.querySelector function. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.