我想从webViewEventHandlers.js中的导出const类调用ComposeBox.js中的handleSend函数
ComposeBox.js
class ComposeBox extends PureComponent<Props, State> {
handleSend = () => {
const { dispatch } = this.props;
const { message } = this.state;
dispatch(addToOutbox(this.getDestinationNarrow(), message));
this.setMessageInputValue('');
};
export default connect((state: GlobalState, props) => ({
auth: getAuth(state),
}))(ComposeBox);
webViewEventHandlers.js
import ComposeBox from '../compose/ComposeBox';
export const handleMessageListEvent = () => {
case 'wizrep':
ComposeBox.handleSend();
break;
我遇到以下错误
答案 0 :(得分:0)
React手册指出:All React components must act like pure functions with respect to their props.
这意味着尝试创建Component的实例并将其视为对象会给您带来很大的困难。
根据您发送的代码段,我可以想象一些可能的解决方法: