그래서 결국 해냈습니다. 이 내용들이 다른 누군가에게 도움이 될 수 있을 것 같아, 컴포넌트에서 제가 놓치고 있었던 부분을 공유합니다:
이것은 일반적으로 유용한 문서라고 하기는 어렵지만, 누군가 필요할 때 도움이 될 수도 있겠고 (아니면 다음에 제가 필요할 때 다시 찾을 수도 있겠네요!).
import { tracked } from '@glimmer/tracking';
...
@tracked myRating
constructor() {
super(...arguments);
this.userRatings = this.args.topic.user_ratings; // tracked 프로퍼티 초기화
if (!this.args.topic.user_ratings) {
return [];
}
const ratingId = this.args.id;
const rating = this.args.topic.user_ratings.find((rating) => Number(rating.rating_id) === Number(ratingId));
this.myRating = rating?.rating_value;
}
....
// 그리고 값을 변경하는 액션에서는:
this.myRating = Number(newStatus);