# 定时器问题

react 组件里使用定时器时得注意清除定时器，否则组件在卸载的时候，定时器还在运行。定时器开启和清除的地方

```javascript
componentDidMount(){

    this.timeID = setTimeout(function(

            console.log(222)
      ){},200)

}


componentWillUnmount(){


    clearTimeout(this.timeID);


}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sekin.gitbook.io/react/ding-shi-qi-wen-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
