react-hot-loader
을 사용할 때 이상한 문제가 발생합니다. React 반응 핫 로더를 사용할 때 최대 호출 스택 크기를 초과했습니다.
Uncaught RangeError: Maximum call stack size exceeded at PatientEdit.__test__REACT_HOT_LOADER__
class PatientEdit extends React.Component {
test =() => {
return 123
}
constructor(props) {
super(props)
}
static propTypes = {
}
render() {
return (
<div>{this.test()}</div>)
}
}
을 던질 것이다 그러나 다음 세 가지가 문서로 하였다 모든 권리
// A
class PatientEdit extends React.Component {
test(){
return 123
}
constructor(props) {
super(props)
}
static propTypes = {}
render() {
return (
<div>{this.test()}</div>)
}
}
// B
class PatientEdit extends React.Component {
test(){
return 123
}
constructor(props) {
super(props)
}
static propTypes = {}
render() {
return (
<div>{this.test()}</div>)
}
}
// C
class PatientEdit extends React.Component {
test =() => {
return 123
}
static propTypes = {}
render() {
return (
<div>{this.test()}</div>)
}
}
로더 구성 말합니다 : .babelrc
아래와 같은 파일 전에 babel-polyfill
및 react-hot-loader/patch
를 추가 엔트리
// .babelrc
{
"presets": [["env", {"modules": false}], "react", "stage-1"],
"plugins": [
"react-hot-loader/babel",
"transform-decorators-legacy",
"transform-flow-strip-types",
"transform-object-assign",
"transform-runtime",
"typecheck",
"react-css-modules"
]
}
처음에는 이상한 행동에 너무 충격을 받고 오류 스택을 무시했습니다. 이제는 내 시간을 react-hot-loader
의 메커니즘과 환영 상세한 설명을 들여다 보니
그래서'A'와'B'는 작동하지만'C'는 작동하지 않습니까? – Chris
this.test.bind (this)를 사용해 보셨습니까? – rrd
현재 코드에는 아무런 문제가 없습니다. 다시 렌더링 할 수있는 테스트 기능에서 다른 작업을 수행하지 않으시겠습니까? –