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

Chap03
Yiqing Zhu 2022-03-26 17:00:21 +11:00
parent 7dd02a76ea
commit b4d0fed5cb
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 = () => {
<div> const handleSearchInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
<a href="./">Q & A</a> console.log(e.currentTarget.value);
<input type="text" placeholder="Search ..." /> };
<a href="./signin">
<UserIcon /> return (
<span>Sign In</span> <div>
</a> <a href="./">Q & A</a>
</div> <input
); type="text"
placeholder="Search ..."
onChange={handleSearchInputChange}
/>
<a href="./signin">
<UserIcon />
<span>Sign In</span>
</a>
</div>
);
};