> 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="/files/2VvUTXB7pbCheEQ6LzHW" 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="/files/lltq6qqkfXMF2BvfuAGC" 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="/files/646bl54tAHjV8msMzmj4" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
