File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,14 +18,19 @@ export default function App() {
1818 </ div >
1919 < input
2020 placeholder = '搜索评论'
21- onKeyDown = { async ( e ) => {
21+ onKeyDown = { ( e ) => {
2222 if ( e . key === 'Enter' && promiseRef . current ) {
2323 e . preventDefault ( )
2424 // `e.currentTarget` will be null after `await`
2525 const keyword = e . currentTarget . value
26- const allComments = await promiseRef . current
27- const comments = searchComments ( allComments , keyword )
28- setComments ( comments )
26+ promiseRef . current
27+ . then ( ( allComments ) => {
28+ const comments = searchComments ( allComments , keyword )
29+ setComments ( comments )
30+ } )
31+ . catch ( ( e ) => {
32+ console . error ( e )
33+ } )
2934 }
3035 } }
3136 />
@@ -54,7 +59,7 @@ const CommentTree: React.FC<CommentProps> = ({ comments, sub = false }) => {
5459 if ( ! comments ) return null
5560 return (
5661 < ul >
57- { comments ? .map ( ( comment ) => (
62+ { comments . map ( ( comment ) => (
5863 < li
5964 key = { comment . rpid }
6065 className = 'comment-item'
You can’t perform that action at this time.
0 commit comments