Withrouter Error using function component and typescript jsx.element' is not assignable to parameter of type routecomponentprops

Viewed 136

I am using react typescript with function component. Trying to pass props to sub component named Input.tsx which defined interface for props. While export with withrouter getting this error. Please anyone help me.

jsx.element' is not assignable to parameter of type 'componenttype<routecomponentprops<any, staticcontext, unknown>>'

Input.tsx file:

import React from 'react';
import { withRouter} from 'react-router-dom';

interface Inputbtn {
  id: string,
  name: string,
  type: string,
  value: string,  
  onChange: (str: string) => void;
}

const Inputbtn = (props: Inputbtn) => {
  return (
    <div className="form-group">
      <div>
        <input          
          id={props.id}
          name={props.name}
          type={props.type}
          value={props.value}          
          onChange={event => props.onChange(event.target.value)}
        />        
      </div>
    </div>
  );
}

export default withRouter(Inputbtn);


1 Answers
Related