# useValue

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

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

```bash
yarn add @corets/use-value
```

{% endtab %}

{% tab title="npm" %}

```
npm install --save @corets/use-value
```

{% endtab %}
{% endtabs %}

This is a React integration for this package:

{% content-ref url="/pages/-MeeBGx8X2I9UAm40nt5" %}
[Value](/observables/value.md)
{% endcontent-ref %}

## useValue() <a href="#usevalue" id="usevalue"></a>

Use observable values inside React components:

```typescript
import React from "react"
import { createValue } from "@corets/value"
import { useValue } from "@corets/use-value"

const globalValue = createValue(0)

const Example = () => {
  const value1 = useValue(0)
  const value2 = useValue(() => 0)
  const value3 = useValue(globalValue)
  
  // alternative syntax
  const [value, setValue] = useValue(globalValue).use()
  
  const increment = () => value1.set(value1.get() + 1)
  
  return <button onClick={increment}>Count: {value1.get()}</button>
}
```


---

# 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/hooks/use-value.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.
