Skip to content

Commit

Permalink
enhance: seach field client component (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
carledwardfp authored Apr 2, 2022
1 parent 6fded95 commit 1d935ea
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions components/SearchField.client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { unstable_useRefreshRoot as useRefreshRoot } from 'next/streaming'
import React, { useState, useTransition } from 'react'
import React, { useTransition } from 'react'
import Spinner from './Spinner'

export default function SearchField() {
const refresh = useRefreshRoot()
const [text, setText] = useState('')
const [isSearching, startSearching] = useTransition({ timeoutMs: 200 })

return (
Expand All @@ -15,12 +14,10 @@ export default function SearchField() {
<input
id="sidebar-search-input"
placeholder="Search"
value={text}
onChange={e => {
const newText = e.target.value
setText(newText)
refresh({ searchText: newText })
startSearching(() => {})
startSearching(() => {
refresh({ searchText: e.target.value })
})
}}
/>
<Spinner active={isSearching} />
Expand Down

1 comment on commit 1d935ea

@vercel
Copy link

@vercel vercel bot commented on 1d935ea Apr 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.