다음과 같은 hyperHTML 구성 요소가 있습니다. 의도 한대로 모든 것이 작동하지만 유일한 문제는 모든 구성 요소 DOM이 모든 this.setState()
호출에서 렌더링된다는 것입니다.HyperHTML - 전체 구성 요소 DOM을 다시 렌더링하지 않고도 구성 요소 상태를 업데이트 할 수 있습니까?
내 질문 :
전체 구성 요소의 DOM 렌더링 다시없이 DOM의 알림 문자열을 업데이트 할 수있는 방법이 있습니까?
const { hyper } = hyperHTML;
class searchComponent extends hyper.Component {
constructor(data) {
super();
this.setState({ notification: '' });
}
onChange() {
// ...
if (condition) {
this.setState(() => ({ notification: 'notification text!' }));
}
// ...
}
async listTags() {
//...
// async content
//...
}
render() {
this.html `
<div id="search_container">
<select name="tags" id="tags_search" class='form-control m0' multiple="multiple" onChange=${this.onChange}>
${{
any: this.listTags(),
placeholder: 'incoming..!',
}}
</select>
<div class="search_notification">
<!-- I want to re render only this part of the DOM -->
${this.state.notification}
</div>
</div>
`
}
}
감사의 예를 볼 수있다, 내 샘플 코드는 거친 추상화입니다. 무엇이 잘못되었는지 설명하여 답변에서 따라온 접근 방식이 마음에 듭니다! – nedo