3
On the first tag <Link>
is making a mistake in the onClick
and I don’t understand why.
Please help me out:
import Link from 'next/link';
import React, { useState } from 'react';
export default function SignIn() {
const [name, setName] = useState('');
const [room, setRoom] = useState('');
return (
<div className="joinOuterContainer">
<div className="joinInnerContainer">
<h1 className="heading">Join</h1>
<div>
<input placeholder="Name" className="joinInput" type="text" onChange={(event) => setName(event.target.value)} />
</div>
<div>
<input placeholder="Room" className="joinInput mt-20" type="text" onChange={(event) => setRoom(event.target.value)} />
</div>
<Link onClick = { e => ( ! Nome || ! Sala ) ? e . preventDefault ( ) : null } to = { `/ chat? name = $ { name } & room = $ { room } ` }>
<button className={'button mt-20'} type="submit">Sign In</button>
</Link>
</div>
</div>
);
}
Error:
Type '{ Children: Element; onClick: (e: any) => any; to: string; }' is not Assignable to type 'Intrinsicattributes & Linkprops & { Children?: Reactnode; }'. Property 'onClick' does not exist on type 'Intrinsicattributes & Linkprops & { Children?: Reactnode; }'. ts(2322)
what error? more detail your question
– Cmte Cardeal
typescript responds: Type '{ Children: Element; onClick: (e: any) => any; to: string; }' is not Assignable to type 'Intrinsicattributes & Linkprops & { Children?: Reactnode; }'. Property 'onClick' does not exist on type 'Intrinsicattributes & Linkprops & { Children?: Reactnode; }'. ts(2322)
– Linecker Rios