좋아요. ReactJS를 수정하고 간단한 예제로 작업하고 있습니다. 모든 것이 잘 작동하며 이미 생산성이 향상되었다고 느낍니다. 이제 앱 이름을 사용하고 Enter 키 누름이 감지되면 콘솔에 기록하는 간단한 React 예제를 작성하고 있습니다. 입력 상자에 앱 이름을 입력하고 엔터 키를 누를 때까지 콘솔 로그에서 볼 수있는 것은 입력 값이 아니라 "정의되지 않은"값입니다. 전체 JS 코드는 다음과 같습니다.React 구성 요소의 소품에 액세스
"use strict";
var InputText = React.createClass({
render() {
return <div><p>Please input the app name you wish to access:</p></div>
}
});
var InputBox = React.createClass({
onKeyPress(e) {
if (e.key === 'Enter') {
console.log(this.props.value);
}
},
render() {
return <input type="text" onKeyPress={this.onKeyPress}></input>
}
});
var AppForm = React.createClass({
render() {
return <div class="appForm">
<InputText />
<InputBox />
</div>
}
});
var App = React.createClass({
render() {
return <AppForm />
}
});
ReactDOM.render(
<App />,
document.getElementById("container")
);