const [keyword, setKeyword] = useState('');
const onClick = (keyword) => {
console.log('enter 누름', keyword);
dispatch(loadPostsInitAction());
dispatch(loadSearchPostsAction({ page, keyword }));
};
const onKeyPress = (e) => {
if (e.key == 'Enter') {
onClick(keyword);
}
};
const handleInput = (e) => {
console.log(e.target.name);
console.log(e.target.value);
setKeyword(e.target.value);
};
return (
<>
<SearchLayout />
<StyledSearchContainerDiv>
<StyledSearchDiv>
<SearchOutlined style={{ position: 'absolute', fontSize: '2rem', left: '10px', zIndex: '1', top: '1rem' }} />
<Input
placeholder="검색어를 입력하세요."
className="search-Input"
onKeyPress={onKeyPress}
value={keyword}
onChange={handleInput}
name="keyword"
/>
</StyledSearchDiv>
{Array.from('fooooooooooo').map(() => (
<PostBox />
))}
</StyledSearchContainerDiv>
</>
);
https://kmhan.tistory.com/315