내 RN 애플리케이션에 propTypes
을 사용하려하지만 결코 적용되지 않는 것 같습니다. React 네이티브 propType이 작동하지 않습니다.
<Table data= { 2000 } />
그래서 내가
Table
의 정적 속성 때문에
propTypes
을 시도 :
import React, { Component } from "react";
import { Text } form "react-native";
export class Table extends Component {
render() {
return (<Text>...</Text>);
}
}
Table.propTypes = {
data: React.PropTypes.string,
};
이 내가이 같은 다른 파일에서 구성 요소에 번호를 통과 경고하지 않았다 내 구성 요소는 다음과 같이 보입니다
import React, { Component } from "react";
import { Text } form "react-native";
export class Table extends Component {
static propTypes = {
data: React.PropTypes.string,
};
render() {
return (<Text>...</Text>);
}
}
가 그럼 난 내
.babelrc
FIL에 플러그인을 추가하는 시도 : 나는 propTypes와 그런 식으로 작업 ES6에 대한 몇 가지 물건을 보았다 나는 소품을 시도했습니다 전자
"plugins": [
"transform-class-properties",
]
은 행운과 export default class Table...
에 export class Table...
을 변경
static propTypes = {
data: React.PropTypes.string.isRequired,
};
나도 해봤이 필요합니다. 위에 나열된 방법의 모든 조합을 사용해 보았습니다. 내가 뭘 놓치고 있니?
export default class Link extends Component {
render() {
return (
<Text >{this.props.text || 'Text'}</Text>
)
}
}
Link.propTypes = {
text: React.PropTypes.string,
}
그것을 시도 :
나는 당신이 이것을 알고 있는지 잘 모른다. "equals"문자를 사용하여 소품을 전달해야합니다.
내 게시물의 오타 였지만 실제 코드는'='를 사용합니다. 내 포스트에서 수정했습니다. – mithunm93
반응 형 proptypes는 개발 환경에서만 작동하므로 env –