TypeError: undefined is not an object(evaluating 'a.PropTypes.func')
There are many similar kinds of questions are available there, But mine is still different because the most of the questions have given the solution like use:
import PropTypes from 'prop-types';
as a separate package and not from:
import React, { Component, PropTypes } from 'react';
Which I am already doing since I have started my project. Still,I am facing the same issue. Below is one of the place in my code where I am using proptypes:
highlightColour: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired
};
and
MonthYearPad.propTypes = {
highlightColour: PropTypes.string.isRequired,
onMonthPress: PropTypes.func.isRequired,
onYearPress: PropTypes.func.isRequired
};
Edit: i also installed it with npm install --save prop-types
Edit: this may also help you understand better:
render() {
return (
<View style={styles.container}>
<InputGroup
title="Month"
groups={monthGroups}
highlightColour={this.props.highlightColour}
onPress={this.props.onMonthPress}
/>
<InputGroup
title="Year"
groups={yearGroups}
highlightColour={this.props.highlightColour}
onPress={this.props.onYearPress}
isLast
/>
</View>
);
}
}
MonthYearPad.propTypes = {
highlightColour: PropTypes.string.isRequired,
onMonthPress: PropTypes.func.isRequired,
onYearPress: PropTypes.func.isRequired
};
export default MonthYearPad;