Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

filter based on input typing react

const List = ({ data }) => {
  const [value, setValue] = useState('')

  return (
    <div>
      <input 
        type="text"
        value={value} 
        onChange={e => setValue(e.target.value)} 
      />

      {data
        .filter(item => {
          if (!value) return true
          if (item.title.includes(value) || item.text.includes(value)) {
            return true
          }
        })
        .map(item => (
          <div>
            <h1>{item.title}</h1>
            <p>{item.text}</p>
          </div>
        ))
      }
    </div>
  )
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm request cancel 
Javascript :: remove unused javascript angular 
Javascript :: react native tdd emzyme 
Javascript :: window.location.href breaks back button 
Javascript :: play mp4 vue js 
Javascript :: java jsp attribute qualified names must be unique within an element 
Javascript :: Differences between detach(), hide() and remove() - jQuery 
Javascript :: binding variable with td in angular site:stackoverflow.com 
Javascript :: react native gridient button 
Javascript :: angular ngbtooltip z-index 
Javascript :: bootstrap 4 without javascript 
Javascript :: why does it say require is not defines 
Javascript :: npm ln 
Javascript :: react native on expo finger print is working bt not in apk 
Javascript :: get number of elements in hashmap javascript 
Javascript :: onclick confirm jquery anchor tag 
Javascript :: how to call javascript function in html using thymeleaf and put argumnet as method arg 
Javascript :: package.json laravel best 
Javascript :: ui5 React bind element 
Javascript :: node command get to much time 
Javascript :: Duplicate module name: React Native hasteimpl react native android 
Javascript :: how to detect if app is loosing focuse in react native 
Javascript :: can I pass function as prop on route change 
Javascript :: how create array with names of files in folder nodejs 
Javascript :: Programação web com Node e Express Beneficiando-se da stack JavaScript 
Javascript :: javascript canvas 1px line 
Javascript :: _40 0 _55 null _65 0 _72 null react native fetch 
Javascript :: dom-to-image bad quality 
Javascript :: regular expression arabic and persion 
Javascript :: what does results.push({}) nodejs mean 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =