我正在尝试获取连接的redux组件的实例,但是,不幸的是,我不能。您能否让我知道我做错了什么或提出建议。我没有发现与我的问题有关的任何例子。
class Packages extends Component {
constructor(props) {
super(props);
this.state = {
showFilterOverlay: false
};
this.openMobileFilterStatus = this.openMobileFilterStatus.bind(this);
}
openMobileFilterStatus(e) {
//
}
render() {
let { packages, match, hasError, error } = this.props;
return( {packages ? (
<PackagesFilterPills
history={this.props.history}
removeRegion={openMobileFilterStatus}
/>
) : null}
)
}
}
function mapStateToProps(state) {
return {
itineraryId: state.app.itineraryId
};
}
function mapDispatchToProps(dispatch) {
return {
actions: {
getPackages: bindActionCreators(getPackages, dispatch)
}
};
}
export default connect(mapStateToProps, mapDispatchToProps, null, {
withRef: true
})(Packages);
对于我的测试用例,我是这样创建的,
it('FilterBar::Snapshot::WithoutArguments', (done) => {
let insElement = shallow(<Provider store={}><PackagesV3 {...LocalProps} /></Provider>);
// here i can't able to get the instance using insElement.instance()
});
请给我一些建议吗?