В функциональном компоненте вы не используете ключевое слово this
.
Я изменил ваш код, чтобы он работал:
import React, { useState } from "react";
import Helmet from "react-helmet";
import "./reg-style/Credentail.css";
import "react-phone-number-input/style.css";
import PhoneInput from "react-phone-number-input";
export default function Credential(props) {
const alter = e => {
e.preventDefault();
props.nextStep();
};
const back = e => {
e.preventDefault();
props.prevStep();
};
const {values, handleChange} = props;
const [value, setValue] = useState();
return (
<div>
<Helmet>
<body className="form-bg-col" />
</Helmet>
<div className="login">
<div className="reg-container">
<button onClick={back} className="col-form-prev">
<i class="fa fa-chevron-left" />
</button>
<div className="user-detail email">
Email:
<input
onChange={handleChange("Email")}
defaultValue={values.Email}
type="email"
placeholder="Enter your Email"
/>
</div>
<div
className="user-detail"
onChange={handleChange("Phone")}
defaultValue={values.Phone}
>
Phone:
<PhoneInput
displayInitialValueAsLocalNumber
placeholder="Enter phone number"
defaultCountry="IN"
value={value}
onChange={setValue}
/>
</div>
<div className="user-detail username">
Username:
<input
onChange={handleChange("Username")}
defaultValue={values.Username}
type="text"
placeholder="Select your unique Username"
/>
</div>
<div className="user-detail password">
Password:
<input
onChange={handleChange("Password")}
defaultValue={values.Password}
type="password"
placeholder="Choose your Password"
/>
</div>
<button onClick={alter} className="col-form-next">
<i class="fa fa-chevron-right" />
</button>
</div>
</div>
</div>
);
}
Можете ли вы увидеть, что я сделал ?
line 7: added props param
line 10 & 15: removed "this"
line 18: removed "this" and changed from [values, handleChange] to {values, handleChange} in order to destructuring your props object