File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ export const RemoteDataSetExample2 = memo(() => {
6666 loading = { loading }
6767 useFilter = { false } // set false to prevent rerender twice
6868 textInputProps = { {
69- placeholder : 'Type 3+ letters' ,
69+ placeholder : 'Type 3+ letters (dolo...) ' ,
7070 autoCorrect : false ,
7171 autoCapitalize : 'none' ,
7272 style : {
Original file line number Diff line number Diff line change @@ -15,17 +15,20 @@ export const RemoteDataSetExample3 = memo(() => {
1515
1616 const getSuggestions = useCallback ( async q => {
1717 console . log ( 'getSuggestions' , q )
18+ const filterToken = q . toLowerCase ( )
1819 if ( typeof q !== 'string' || q . length < 3 ) {
1920 setSuggestionsList ( null )
2021 return
2122 }
2223 setLoading ( true )
2324 const response = await fetch ( 'https://jsonplaceholder.typicode.com/posts' )
2425 const items = await response . json ( )
25- const suggestions = items . map ( item => ( {
26- id : item . id ,
27- title : item . title ,
28- } ) )
26+ const suggestions = items
27+ . filter ( item => item . title . toLowerCase ( ) . includes ( filterToken ) )
28+ . map ( item => ( {
29+ id : item . id ,
30+ title : item . title ,
31+ } ) )
2932 setSuggestionsList ( suggestions )
3033 setLoading ( false )
3134 } , [ ] )
@@ -65,7 +68,7 @@ export const RemoteDataSetExample3 = memo(() => {
6568 loading = { loading }
6669 useFilter = { false } // prevent rerender twice
6770 textInputProps = { {
68- placeholder : 'Type 3+ letters' ,
71+ placeholder : 'Type 3+ letters (dolo...) ' ,
6972 autoCorrect : false ,
7073 autoCapitalize : 'none' ,
7174 style : {
You can’t perform that action at this time.
0 commit comments