# State

### **Code**

```jsx
const [data, state, request] = useApi(config, options)
```

### **First State (before calling API)**

The first state has only one property `loading` before calling **API**.

| Name      | Type    | Default | Description                                       |
| --------- | ------- | ------- | ------------------------------------------------- |
| loading   | boolean | false   | To indicate whether calling api or not.           |
| fromCache | boolean | false   | To tell whether the data come from SSR API cache. |

### **Full State**

The is the full state data structure after the api has responded.

| Name           | Type              | Default   | Description                                                                                                                                                                       |
| -------------- | ----------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| loading        | boolean           | false     | To indicate whether calling api or not.                                                                                                                                           |
| fromCache      | boolean           | false     | To tell whether the data come from SSR API cache.                                                                                                                                 |
| data           | any               | undefined | The processed data provided from `options.handleData`.                                                                                                                            |
| response       | AxiosResponse     | undefined | The Axios' response.                                                                                                                                                              |
| error          | AxiosError        | undefined | The Axios' error.                                                                                                                                                                 |
| dependencies   | Object            | undefined | The additional needed data using in handleData. `NOTE`: "dependencies" is supposed to immutable due to React's rendering policy.                                                  |
| prevData       | any               | undefined | The previous data of the previous state.                                                                                                                                          |
| prevState      | ReactUseApi.State | undefined | The previous state.                                                                                                                                                               |
| \[custom data] | any               |           | You can add your own custom state data into the state by setting up in `options.handleData`. For example, `state.foo = 'bar'`. The data always be preserved whether re-rendering. |


---

# 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://react-use-api.gitbook.io/react-use-api/api/state.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.
