У меня есть следующая функция:
export default function InstitutionInfoScreen({route, navigation}) {
const { title, image, logo, location, phone, email } = route.params;
return (
<ScrollView >
<View style={styles.whiteContainer}>
<InstItem navigation={navigation}/>
</View>
</ScrollView>
);
}
Оказывается, я хочу, чтобы InstItem получил параметр навигации, потому что он мне нужен для моего компонента SliderEntry. InstItem выглядит так:
class InstItem extends React.Component {
constructor(props){
super(props);
this.state = {
activeSlide: SLIDER_1_FIRST_ITEM
};
}
_renderItemWithParallax ({item, index}, parallaxProps) {
return (
<SliderEntry
navigate={this.props.navigation}. <-- THIS IS THE ISSUE
type="institution"
data={item}
even={(index + 1) % 2 === 0}
parallax={true}
parallaxProps={parallaxProps}
/>
);
}
render(){
return (
<View style={styles.whiteContainer}>
<Carousel
ref={c => this._slider1Ref = c}
data={DATA2}
renderItem={this._renderItemWithParallax}
sliderWidth={sliderWidth}
itemWidth={itemWidth}
hasParallaxImages={true}
firstItem={SLIDER_1_FIRST_ITEM}
inactiveSlideScale={0.94}
inactiveSlideOpacity={0.7}
// inactiveSlideShift={20}
containerCustomStyle={styles.slider}
contentContainerCustomStyle={styles.sliderContentContainer}
loop={true}
loopClonesPerSide={2}
onSnapToItem={(index) => this.setState({ activeSlide: index }) }
/>
<Pagination
dotsLength={DATA2.length}
activeDotIndex={this.state.activeSlide}
containerStyle={styles.paginationContainer}
dotColor={'rgba(46, 49, 49, 1)'}
dotStyle={styles.paginationDot}
inactiveDotColor={colors.navyblue}
inactiveDotOpacity={0.4}
inactiveDotScale={0.6}
carouselRef={this._slider1Ref}
tappableDots={!!this._slider1Ref}
/>
</View>
);
}
}
Однако я всегда получаю:
typeerror undefined is not an object (evaluating 'this.props.navigation')
Я пытался использовать «навигацию» напрямую вместо «this.props.navigation», но это не так. тоже не работает. Как я могу это исправить?