他,我试着修改< extension > shoutem.places 这个扩展。我的自定义屏幕如下所示:
import { screens } from 'shoutem.places';
export default class FixedMediumPlaceDetails extends
screens.MediumPlaceDetails {
render() {
const { place } = this.props;
const { location = {} } = place;
return (
<Screen>
<NavigationBar />
<ScrollView>
{this.renderLeadImage(place)}
</ScrollView>
</Screen>
);
}
}我只是覆盖了render()方法,在这个方法中,我想从超类中调用renderLeadImage()方法。
通过这个实现,我得到了:this.renderLeadImage() is not a function。那么如何正确地继承类并调用超类的方法呢?无论如何,继承是这里的首选方式吗?Facebook推荐组合而不是继承。
发布于 2017-07-10 15:07:34
screens.MediumPlaceDetails不是一个React组件类,而是一个redux和shoutem.theme装饰类,这就是为什么当你进行扩展时,你不能访问renderLeadImage()的任何方法。
所以你必须更改你的import
import { MediumPlaceDetails } from 'shoutem.places/screens/MediumPlaceDetails';编辑:修复复制-粘贴错误。
https://stackoverflow.com/questions/45001157
复制相似问题