http://codepen.io/JessieZhou/pen/VPgMdP 다음은 CodePen에서 React를 사용하는 데모이지만 브라우저는 "Uncaught ReferenceError : Component is not defined"오류 메시지를 표시합니다. 그러나 첫 번째 줄에 "react {from {Component}"가져 오기} 줄을 삽입하면 "Uncaught ReferenceError : require is not defined"오류가 발생합니다. '클래스'를 사용하면이 문제가 발생할 수 있습니까? 여기 Codepen에서 es6을 사용하여 반응하는 방법
내 코드입니다 : 여기//import {Component} from 'react'
class MyInput extends Component{
constructor(props){
super(props);
this.handleChange = this.handleChange.bind(this);
}
handleChange(e){
this.props.update(e.target.value);
}
render(){
return <input onChange={this.handleChange} type="text"/>
}
}
ReactDOM.render(MyInput, document.getElementById('myinput'));
가 CodePen 내 자바 스크립트 설정 : javascript settings in codepen
가 대단히 감사합니다 :
//unpkg.com/react/umd/react.development.js
//unpkg.com/react-dom/umd/react-dom.development.js
의 예는 16.2 반작용에서 작동 있습니다! 사용 React.Component 작동하지만 구성 요소를 사용하려면 "가져 오기 {Component}에서 '반응'"여전히 작동하지 않는, 오류 "Uncaught ReferenceError : 필요가 정의되지 않았습니다."... – JessieZhou
이 줄을 사용하십시오. 우리가 lib 링크를 사용하기 위해 사용했던 codepen에서, 우리는 완전한 React.Component를 사용해야 만합니다. –