# \<Memo />

Source code is hosted on [GitHub](https://github.com/corets/memo)

{% tabs %}
{% tab title="yarn" %}

```bash
yarn add @corets/memo
```

{% endtab %}

{% tab title="npm" %}

```
npm install --save @corets/memo
```

{% endtab %}
{% endtabs %}

## \<Memo /> <a href="#memo-1" id="memo-1"></a>

Memoizes children components to prevent unnecessary re-renders. Children get re-rendered only when one of the fields passed into the `deps` array changes, very similar to how `useEffect`, `useMemo` and `useCallback` work. You can also display the render count for debugging purposes by setting the `showRenders` property to `true`.

```typescript
import React, { useState } from "react"
import { Memo } from "@corets/memo"

const Example = () => {
  const [a, setA] = useState(0)
  const [b, setB] = useState(0)
  const incrementFirstValue = () => setA(a + 1)
  const incrementSecondValue  = () => setB(b + 1)
  
  return (
    <div>
      <div>A: {a}</div>
      <div>B: {b}</div>
      
      <Memo deps={[b]} showRenders>
        <div>Memo: will only re-render when <code>b</code> changes</div>
        <div>A: {a}</div>
        <div>B: {b}</div>
      </Memo>
      
      <button onClick={incrementFirstValue}>Increment A</button>
      <button onClick={incrementSecondValue}>Increment B</button>
    </div>
  )
}
```


---

# 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://docs.corets.io/components/memo.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.
