我是新来的react-redux。现在我正在进行一个react-redux项目。当我的输入在输入标签中改变时,我想调用一个函数。为此,我申请“的onchange”事件在这个喜欢如何在react-redux中调用函数
<input {...this.props} onchange="this.callHandler(this.value)"/>
onchange事件处理程序调用的函数“callHandler”,这是定义为
callHandler = (value) => {
console.log("value in input",value);
}
我不知道为什么这个功能不叫。
我给这部分完整的代码:
import React from 'react';
type PropsType = {
};
export default class InputComponent extends React.Component<void, PropsType, void> {
callHandler = (value) => {
console.log("value in input",value);
}
render() {
console.log("InputComponent props",this.props);
const inputStyle = this.props.inputStyle;
return (
<input {...this.props} onchange="this.callHandler(this.value)"/>
);
}
}
我也不知道为什么我们使用{...} this.props。
在此先感谢。
现在它的工作。谢谢。 –
您是否知道我们在此使用{... this.props} –
@Kelltontech,请参阅评论的下半部分。我正在进一步扩展,但希望现在给出一个基本的了解 –