> For the complete documentation index, see [llms.txt](https://docs.jigx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jigx.com/examples/readme/actions/state-actions/reset-state.md).

# reset-state

`Reset-state` action is typically used to reset the state of the key inside the jig file and can be used further to reset the state of UI components and forms. To understand how to use states, see [State](https://docs.jigx.com/building-apps-with-jigx/logic/state).

## Configuration options

There are multiple ways to set up a reset-state action within a jig:

1. As `onFocus` action that will be executed.
2. As `onRefresh` action that will be executed.
3. As the main action on the jig, and when you press the action, the `reset-state` action will be executed.
4. The `onPress` and `onChange` actions will be executed when you trigger the `onPress` or `onChange` event.

Some properties are common to all actions, see [Common action properties](/examples/readme/actions/common-action-properties.md) for the list of actions and their configuration options.

## Examples and code snippets

### reset-state - component state

<figure><img src="https://1414514342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHcPzbms3kZejTmFd500V%2Fuploads%2Fy7aX8AnZYlD8rMXkssXw%2FReset-state-action.PNG?alt=media&amp;token=95994b15-fd30-4fb9-90ac-d551ea6b4070" alt="Reset-state action" width="563"><figcaption><p>Reset-state action</p></figcaption></figure>

1. Reset-state action is used as the primary action on the jig, to reset-state of the component in the jig and its value.
2. You can specify **instanceId**, this will be the name of the UI component
3. And you need to specify the **key**, which will be the value of the UI component that you want to reset

**Example:**

See the full example in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/reset-state/static-data/reset-state-action-form.jigx).

{% code title="action.jigx" %}

```yaml
actions:
  - children:
      - type: action.reset-state
        options:
          title: Reset state of the form
          state: =@ctx.components.form.state.data
```

{% endcode %}

### reset-state - solution state in onFocus/onRefresh

<figure><img src="https://1414514342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHcPzbms3kZejTmFd500V%2Fuploads%2F438cId9Q1E1C37p4Cp2d%2FReset-state-onFocus.PNG?alt=media&amp;token=ea446651-bd14-45de-8acf-37a7774bad23" alt="Reset-state onFocus/onRefresh" width="375"><figcaption><p>Reset-state onFocus/onRefresh</p></figcaption></figure>

1. Reset-state action is used when the onFocus/onRefresh event is triggered to reset the component's state or key.
2. You can specify instanceId, this will be the name of the UI component.
3. And you need to specify the key, which will be the value of the UI component or the name of the key that you want to reset.

**Example:** See the full example in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/reset-state/static-data/reset-state-focus-load-refresh.jigx).

{% tabs %}
{% tab title="onFocus.jigx" %}

```yaml
onFocus:
  type: action.reset-state
  options:
    state: =@ctx.solution.state.onFocus-key
```

{% endtab %}

{% tab title="onRefresh.jigx" %}

```yaml
onRefresh:
  type: action.reset-state
  options:
    state: =@ctx.solution.state.onRefresh-key
```

{% endtab %}
{% endtabs %}

### reset-state solution in onPress/onChange

<figure><img src="https://1414514342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHcPzbms3kZejTmFd500V%2Fuploads%2FA3zqaO7QAkWAjTDplHcU%2FReset-state-onPress.PNG?alt=media&amp;token=9c1e4112-18bb-4223-88d2-445e039fcb19" alt="Reset-state onPress/onChange" width="563"><figcaption><p>Reset-state onPress/onChange</p></figcaption></figure>

1. Reset-state action used on the list as **onPress** or **onChange** action, to reset-state of the component.
2. You can specify instanceId, this will be the name of the UI component.
3. And you need to specify the **state**, which will be the value of the UI component that you want to reset

**Example:**

See the full example in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/reset-state/static-data/reset-state-onpress-onchange.jigx).

{% tabs %}
{% tab title="onPress.jigx" %}

```yaml
onPress:
  type: action.reset-state
  options:
    state: =@ctx.solution.state.onPress-key
```

{% endtab %}

{% tab title="onChange.jigx" %}

```yaml
onChange:
  type: action.reset-state
  options:
    state: =@ctx.solution.state.onChange-key
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.jigx.com/examples/readme/actions/state-actions/reset-state.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
