Skip to content

Argument of type '{}' is not assignable to parameter of type 'T' #3359

Closed
@havesomeleeway

Description

/src/container/Login

import * as React from 'react';
import LoginForm from "../components/login/LoginForm"

const initialState = {
    emailOrPhone: ""
};

/** Prevents direct state manipulation  */
type State = Readonly<typeof initialState>


class Login extends React.Component<State> {
    readonly state: State = initialState;

    render() {
        return (
            <LoginForm
                onChange={this.handleEmailOrPhoneChange}
                onSubmit={this.handleSubmit}
                emailOrPhone={this.state.emailOrPhone}/>
        )
    }

    private handleEmailOrPhoneChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
        this.setState({emailOrPhone: evt.target.value});
    };

    private handleSubmit = (evt: React.ChangeEvent<HTMLInputElement>) => {
        evt.preventDefault();
    };
}


export default Login

I have a container component that supposed to pass state to my dummy component and render it.

Upon npm start i'm thrown this error. The only file on my version control list that is changed is the above container component

image

Here's my component code for additional information, but I doubt it's necessary.

import * as React from "react";
import { Button, Card, InputGroup } from "@blueprintjs/core";
import companyLogo from "../../styles/assets/imgs/oromico__logo.png";
import { Link } from "react-router-dom";

/** TypeScript Props from package, used for Input component **/
import { IControlledProps } from "@blueprintjs/core";

export interface LoginProps {
  /** Form value of the input, for controlled usage. */
  emailOrPhone: string,
  /** Form value of the input, for controlled usage. */
  onSubmit: React.FormEventHandler<HTMLElement>;
}


const LoginForm = (props: IControlledProps & LoginProps)  => {
  return (
    <div>
        <InputGroup
          name="emailOrPhone"
          type="email"
          placeholder="Email or phone"
          value={props.emailOrPhone}
          onChange={props.onChange}
          large
        />
        </div>
        <div>
            <Button
              rightIcon="arrow-right"
              intent="primary"
              large
              onSubmit={props.onSubmit}
            >
              Next
            </Button>
    </div>
  );
};


export default LoginForm;

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions