JS 빈 Available herereact.js 구성 요소 : 이벤트를 keyDown 얻을 수없는 경우 다른
내부 구성 요소 I가 내가 키 다운 이벤트를 얻을 대상이되는 ComponentB라는 구성 요소 :
var ComponentB = React.createClass({
render: function() {
return (
<div
contentEditable
onKeyDown={this.handleKeyDown}>{this.props.data}</div>
);
},
handleKeyDown: function(e) {
console.log("B: " + e.type +"-" + e.which);
}
});
I을 이 ComponentB가 main/App 구성 요소 바로 아래에 있으면 해당 이벤트를 가져올 수 있습니다. 나는 내가 (this.props.lines
3 문자열의 배열입니다) 더 이상 이러한 이벤트를받지 못한 다른 구성 요소의 내부 (componentA을)이 구성 요소를 포함하려고하면
는 :
var ComponentA = React.createClass({
render: function(){
return (
<div
contentEditable>
{
this.props.lines.map(function(line,i) {
return <ComponentB key={i} data={line} />
})
}
</div>
);
}
});
연관된 JS BIN이 동작을 보여줍니다 경우 구성 요소 A 섹션에서 선을 편집하려고합니다. 어떤 이벤트도 방출되지 않을 것입니다. 아래의 componentB의 sinbgle 인스턴스를 편집하면 ...
react.js의 버그처럼 보이지만 처음에는 여기를 확인하고 싶습니다.
중첩 된 contentEditable 요소에 문제가있는 것 같습니다. ComponentA에서'contentEditable'을 제거하면 예상대로 작동합니다. –