0
我打電話跟裁判子功能,但孩子的功能有降低作用,故一點兒也不工作:使用REF與mapStateToProps不起作用reactjs
我的父母:
search(data) {
this.SearchProduct.search(data);
}
...
<SearchProduct ref={instance => { this.SearchProduct = instance; }} />
我的孩子:
class SearchProduct extends React.Component {
...
search(data) {
console.log(data)
}
...
}
const mapStateToProps = (state, ownProps) => ({
basket: state.basket,
});
const mapDispatchToProps = (dispatch, ownProps) => ({
setBasket: (basket) => {
dispatch({ type: 'SET_BASKET', basket });
}
});
module.exports = connect(
mapStateToProps,
mapDispatchToProps,
null,
{ withRef: true }
)(SearchProduct);
當我火了:
component.js:25 Uncaught TypeError: this.SearchProduct.search is not a function
任何人有一個想法?
感謝的很多