Chap03 -> Handling events -> Handling an input change event

master
Jason Zhu 2022-03-26 17:00:21 +11:00
parent e3810cc810
commit 27421824c7
1 changed files with 20 additions and 10 deletions

View File

@ -1,13 +1,23 @@
import React from 'react'; import React from 'react';
import { UserIcon } from './Icons'; import { UserIcon } from './Icons';
export const Header = () => ( export const Header = () => {
const handleSearchInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
console.log(e.currentTarget.value);
};
return (
<div> <div>
<a href="./">Q & A</a> <a href="./">Q & A</a>
<input type="text" placeholder="Search ..." /> <input
type="text"
placeholder="Search ..."
onChange={handleSearchInputChange}
/>
<a href="./signin"> <a href="./signin">
<UserIcon /> <UserIcon />
<span>Sign In</span> <span>Sign In</span>
</a> </a>
</div> </div>
); );
};