Reputation: 1253
I am writing an application with reactjs
I want to upload file which is passed as a prop from child component to parent component
Child Component
const RegisterIndividual: React.FC< { upload_id_card: React.ChangeEventHandler<HTMLInputElement>} > = ({
upload_id_card,
handleInput }) => {
return (
<div className="mt-3">
<input
type="file"
name="profile_picture"
id=""
onChange=={upload_id_card}
style={{ display: "block", marginTop: "1rem" }}
/>
</div>
)};
Parent Component
const Register = () => {
const upload_id_card = (event) => {
console.log("type upload file code here")
}
return (
<div className="__register">
<RegisterIndividual upload_id_card={upload_id_card} />
</div>
)}
but I am getting this error on the child component
Type 'true' is not assignable to type 'ChangeEventHandler<HTMLInputElement> | undefined'.ts(2322)
Upvotes: 1
Views: 153
Reputation: 2806
Remove the ==
and replace with =
, you want to assign and not compare:
onChange=={upload_id_card}
Upvotes: 1