> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Function: useContext()

> **useContext**\<`T`>(`context`: `Context`\<`T`>): `T`

接受一个 context 对象（`React.createContext` 返回的值），并返回
当前的 context 值，即该 context 最近的 provider 所提供的值。

## Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

## Parameters

| Parameter | Type            |
| --------- | --------------- |
| `context` | `Context`\<`T`> |

## Returns

`T`

## Version

16.8.0

## See

[https://react.dev/reference/react/useContext](https://react.dev/reference/react/useContext)
