How to call a function in react-redux

Viewed 274

I am new to react-redux. Now I am working on a react-redux project. I want to call a function when my input changes in input tag. For this I apply "onchange" event in this like

 <input {...this.props}  onchange="this.callHandler(this.value)"/> 

onchange event handler call a function "callHandler" which is define as

 callHandler = (value) => {
      console.log("value in input",value);
 }

I don't know why this function is not called.
My full code for this component is :

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)"/>
    );
  }
}

I also don't know why we use {...this.props}.
Thanks in advance.

1 Answers
Related