1# Reuse ID 2 3**reuseId** is an ID that identifies the reuse group of a custom component. The reuse framework identifies and groups reusable custom components based on their reuse IDs. 4 5> **NOTE** 6> 7> This attribute is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version. 8 9 10## reuseId 11 12reuseId(id: string) 13 14Sets the ID that identifies the reuse group of the component. 15 16**Atomic service API**: This API can be used in atomic services since API version 11. 17 18**System capability**: SystemCapability.ArkUI.ArkUI.Full 19 20**Parameters** 21 22| Name| Type | Mandatory| Description | 23| ------ | ------ | ---- | -------------------------------------- | 24| id | string | Yes | ID that identifies the reuse group of the component.| 25 26## Example 27 28```ts 29// xxx.ets 30@Entry 31@Component 32struct MyComponent { 33 @State switch: boolean = true; 34 private type: string = "type1"; 35 36 build() { 37 Column() { 38 Button("ChangeType") 39 .onClick(() => { 40 this.type = "type2" 41 }) 42 Button("Switch") 43 .onClick(() => { 44 this.switch = !this.switch 45 }) 46 if (this.switch) { 47 ReusableChildComponent({ type: this.type }) 48 .reuseId(this.type) 49 } 50 } 51 .width('100%') 52 .height('100%') 53 } 54} 55 56@Reusable 57@Component 58struct ReusableChildComponent { 59 @State type: string = '' 60 61 aboutToAppear() { 62 console.log(`ReusableChildComponent Appear ${this.type}`) 63 } 64 65 aboutToReuse(params: ESObject) { 66 console.log(`ReusableChildComponent Reuse ${this.type}`) 67 this.type = params.type; 68 } 69 70 build() { 71 Row() { 72 Text(this.type) 73 .fontSize(20) 74 .margin({ left: 10 }) 75 }.margin({ left: 10, right: 10 }) 76 } 77} 78``` 79