我已将 PropTypes 更改为 "prop-types" 但仍然出现评估 React.PropTypes 错误
I have changed to PropTypes to "prop-types" but still get Error evaluating React.PropTypes
环境:
OS: Linux 5.3
节点:12.16.1
纱线:1.21.1
npm:6.13.4
守望者:4.9.0
Xcode: N/A
Android工作室:3.5 AI-191.8026.42.35.5791312
Packages: (wanted => installed)
react: ^16.3.0-alpha.0 => 16.13.0
react-native: 0.55.0 => 0.55.0
"dependencies": {
"prop-types": "^15.7.2",
"react": "^16.3.0-alpha.0",
"react-native": "0.55.0",
"react-native-parabolic": "~1.1.1",
"react-native-scrollable-tab-view": "~0.7.1",
"react-native-swiper": "~1.5.4",
"react-native-tab-navigator": "~0.3.3"
}
export default class DefaultTabBar extends Component{
constructor(){
super()
}
static propTypes = {
goToPage: PropTypes.func,
activeTab: PropTypes.number,
tabs: PropTypes.array,
backgroundColor: PropTypes.string,
activeTextColor: PropTypes.string,
inactiveTextColor: PropTypes.string,
textStyle: Text.propTypes.style,
tabStyle: View.propTypes.style,
renderTab: PropTypes.func,
underlineStyle: View.propTypes.style,
};
我该如何解决?
你的问题不清楚。但我认为这是你的问题:
View.propTypes
已弃用。
-> 改为使用 ViewPropTypes
。
import { ViewPropTypes } from 'react-native';
...
underlineStyle: ViewPropTypes.style,
你可以使用这个:
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};
环境:
OS: Linux 5.3 节点:12.16.1 纱线:1.21.1 npm:6.13.4 守望者:4.9.0 Xcode: N/A Android工作室:3.5 AI-191.8026.42.35.5791312
Packages: (wanted => installed)
react: ^16.3.0-alpha.0 => 16.13.0
react-native: 0.55.0 => 0.55.0
"dependencies": {
"prop-types": "^15.7.2",
"react": "^16.3.0-alpha.0",
"react-native": "0.55.0",
"react-native-parabolic": "~1.1.1",
"react-native-scrollable-tab-view": "~0.7.1",
"react-native-swiper": "~1.5.4",
"react-native-tab-navigator": "~0.3.3"
}
export default class DefaultTabBar extends Component{
constructor(){
super()
}
static propTypes = {
goToPage: PropTypes.func,
activeTab: PropTypes.number,
tabs: PropTypes.array,
backgroundColor: PropTypes.string,
activeTextColor: PropTypes.string,
inactiveTextColor: PropTypes.string,
textStyle: Text.propTypes.style,
tabStyle: View.propTypes.style,
renderTab: PropTypes.func,
underlineStyle: View.propTypes.style,
};
我该如何解决?
你的问题不清楚。但我认为这是你的问题:
View.propTypes
已弃用。
-> 改为使用 ViewPropTypes
。
import { ViewPropTypes } from 'react-native';
...
underlineStyle: ViewPropTypes.style,
你可以使用这个:
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};