Skip to content

Commit

Permalink
[update] the setConfig() method
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiipylypchuk1991 committed Sep 8, 2023
1 parent 1bbffd7 commit fd6f9f2
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions docs/api/methods/setconfig_method.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ description: You can learn about the setConfig method in the documentation of th

@short: Sets a new configuration for the To Do List

:::tip
Using this method, you can change configuration of the To Do List widget. The method changes only the parameters you passed
:::

:::info
It is also possible to load data into the To Do List via the method, but we recommend that you use the [`parse()`](api/methods/parse_method.md) method for this purpose
:::

### Usage

~~~js
Expand All @@ -26,11 +18,19 @@ setConfig(config: object): void;

### Parameters

- `config` - (required) an object with new configuration of To Do List. See the full list of properties [here](api/api_overview.md#to-do-list-properties)
- `config` - (required) an object with new configuration of To Do List. See the full list of properties [here](api/api_overview.md#to-do-list-properties)

:::tip
The method changes only the parameters you passed. It is also possible to load data into the To Do List via the method, but we recommend that you use the [`parse()`](api/methods/parse_method.md) method for this purpose.
:::

:::important
The `setConfig()` method destroys the current component and initialize a new one. If you use the component with **Toolbar**, you need to call the [`setConfig()`](api/toolbar_api/methods/setconfig_method.md) method of **Toolbar**, because it uses the internal API of To Do List. See the example below!
:::

### Example

~~~js {17-19,21-23}
~~~js {16-19,21-24}
const { ToDo, Toolbar } = todo;

const list = new ToDo("#root", {
Expand All @@ -51,11 +51,8 @@ list.setConfig({
activeProject: "second"
});

// update configuration parameters of Toolbar
toolbar.setConfig({
api: list.api,
});
~~~

:::info
The To Do List won't be rendered correctly until you call the [`setConfig()`](api/toolbar_api/methods/setconfig_method.md) method of the Toolbar component
:::

0 comments on commit fd6f9f2

Please sign in to comment.