1e41f4b71Sopenharmony_ci#  ArkUI Subsystem Changelog
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci### Restrictions on Using Decorators
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci#### 1. Restrictions on Using Component Decorators
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciComponent decorators @Component, @Entry, @Preview, and @CustomDialog apply only to structs, not classes.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci**Example**
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci```
12e41f4b71Sopenharmony_ci@Component
13e41f4b71Sopenharmony_ci  // ERROR:The '@Component' decorator can only be used with 'struct'.
14e41f4b71Sopenharmony_ciclass Index {
15e41f4b71Sopenharmony_ci  build() {
16e41f4b71Sopenharmony_ci  }
17e41f4b71Sopenharmony_ci}
18e41f4b71Sopenharmony_ci```
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**Change Impact**
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ciIf @Component, @Entry, @Preview, or @CustomDialog is used to decorate components other than structs, a compile time error will occur.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**Key API/Component Changes**
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciN/A
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**Adaptation Guide**
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciUse @Component, @Entry, @Preview, and @CustomDialog to decorate only structs.
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci#### 2. Restrictions on Using Component Member Variable Decorators
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciComponent member variable decorators @State, @Prop, @Link, @Provide, @Consume, @ObjectLink, @StorageLink, @StorageProp, @LocalStorageLink, @LocalStorageProp, @Watch, and @BuilderParam can decorate only the member variables of structs.
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci**Example**
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci```
39e41f4b71Sopenharmony_ci@Component
40e41f4b71Sopenharmony_ciclass Index {
41e41f4b71Sopenharmony_ci  // ERROR: The '@State' decorator can only be used with 'struct'.
42e41f4b71Sopenharmony_ci  @State message: string = 'Hello world'
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci  build() {
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci  }
47e41f4b71Sopenharmony_ci}
48e41f4b71Sopenharmony_ci```
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**Change Impact**
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciIf any of the aforementioned component member variable decorators is used to decorate a member variable of components other than structs, a compile time error will occur.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**Key API/Component Changes**
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ciN/A
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**Adaptation Guide**
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ciUse the aforementioned component member variable decorators to decorate only the member variables of structs.
61