---
schema_version: "1"
id: 57f56983dbd0a28313e92ddbf61b6f1d090dcea0ddfbc0d73fb22fdf5f875062
title: Lightning Web Component setState Method
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/dashboard-component/guides/bi-dbcomp-lwc-setstatemethod.md
canonical_url: https://developer.salesforce.com/docs/analytics/dashboard-component/guide/bi-dbcomp-lwc-setstatemethod.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: cc994e6a4f40af9413c4eae6f1b28866def6a72f4d8d8154f1cf40e8259f0d14
products:
  - Analytics Dashboard Component
  - analytics
---
# Lightning Web Component setState Method

Use the `setState` method to set the state of the rendered Lightning web component for CRM Analytics dashboards.

## Arguments

| Argument Name | Description                                                                                                                                     |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `state`    | The state to update the CRM Analytics dashboard component with. |


## Example

Add your implementation of the `setState` call into the wrapper Javascript and HTML for your component.

**note:** To use the communityDashboard component, replace `wave-wave-dashboard-lwc` with `wave-community-dashboard`.

The HTML for the component:
```html
<template>
  <lightning-button variant="brand" label="Set Dashboard State" title="Set State Action" onclick={setState} class="slds-m-left_x-small"></lightning-button>
  <wave-wave-dashboard-lwc dashboard="0FK5B000000XiK14AK" height="1000"></wave-wave-dashboard-lwc>
</template>
```

The Javascript for the component, which implements `setState()`:
```javascript
import { LightningElement } from 'lwc';

export default class DashboardWrapper extends LightningElement {
  _state = {};

  setState () {
    const dashboard = this.template.querySelector('wave-wave-dashboard-lwc');
    dashboard.setState(this._state);
    console.warn("setState complete");
  }
}
```

The `state` can be set dynamically from user input or from another dashboard’s `state`. For the complete dashboard `state` structure, refer to the [Analytics Dashboard JSON Reference](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_json.meta/bi_dev_guide_json/bi_dbjson_intro.htm) guide.

**See Also**

- [Lightning Web Component `getState` Method](https://developer.salesforce.com/docs/analytics/dashboard-component/guide/bi-dbcomp-lwc-getstatemethod.md)
