에 자녀의 이벤트를 전달 :내가이 같은 자동 완성 기능을 가진 텍스트 영역을 강화하고 부모
<MentionAutocomplete ref="autocomplete">
<Textarea ref="editor"/>
</MentionAutocomplete>
아이디어는 MentionAutocomplete
자체에 textarea
또는 input
처럼 어떤 일을 사용하고 여전히 작동 할 수 있다는 것입니다.
이 잘 작동과 같은 키보드 이벤트를 듣고 자동 완성 달성 :
<div
className="MentionAutocomplete"
onKeyDown={this.handleKey}
onKeyUp={this.handleKeyUp}
>
{this.props.children}
{this.renderAutocomplete()}
</div>
을하지만 최근 자동 완성 field.value
이 undefined
것을 불평 문제로 달렸다. Textarea
구성 요소가 무언가를하고있을 수도 있고 브라우저 확장이 엉망이 될 수도 있습니다.
var self = this;
<MentionAutocomplete ref="autocomplete">
<Textarea ref="editor" onKeyUp={(event) => self.refs.autocomplete.keyUp(event) } />
</MentionAutocomplete>
하지만 궁금이 오른쪽 접근 방식 :
이상적으로 나는 이런 일을하기를 원하십니까? 더 좋은 방법이 있습니까?
어디에서'field.value'를 사용하고 있습니까? – Sven
'handleKeyUp'에'e.target.value'가 있습니다. – hakunin