Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

filter state based on text field react


  const fruit = ['apple', 'banana', 'orange', 'grapefruit',
    'mango', 'strawberry', 'peach', 'apricot'];
 
  const [filter, setFilter] = useState('');
 
  return (
    <div className="App">
      <p>
        Type to filter the list:
        <input id="filter"
          name="filter"
          type="text"
          value={filter}
          onChange={event => setFilter(event.target.value)}
        />
      </p>
      <ul>
      {fruit.filter(f => f.includes(filter) || filter === '')
            .map(f => <li key={f}>{f}</li>)}
      </ul>
    </div>
  );
Comment

filter state based on text field react


  const fruit = ['apple', 'banana', 'orange', 'grapefruit',
    'mango', 'strawberry', 'peach', 'apricot'];
 
  const [filter, setFilter] = useState('');
 
  return (
    <div className="App">
      <p>
        Type to filter the list:
        <input id="filter"
          name="filter"
          type="text"
          value={filter}
          onChange={event => setFilter(event.target.value)}
        />
      </p>
      <ul>
      {fruit.filter(f => f.includes(filter) || filter === '')
            .map(f => <li key={f}>{f}</li>)}
      </ul>
    </div>
  );
Comment

PREVIOUS NEXT
Code Example
Javascript :: react pdf fixed property not working 
Javascript :: custom validator Whitelisting 
Javascript :: function expession js 
Javascript :: react get padding 
Javascript :: new http version ANGULAR 
Javascript :: js set utils 
Javascript :: react hook for component size 
Javascript :: how to add heaeader to http angular client 
Javascript :: counter random interval 
Javascript :: api call in react chart 
Javascript :: Example of Nullish coalescing assignment operator in es12 
Javascript :: const and let keywords in ES6 
Javascript :: golang json time 
Javascript :: format file using jq 
Javascript :: A Note about Floats 
Javascript :: GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN" electronjs 
Javascript :: angular mat-calendar send to form 
Javascript :: keep form values after submit javascript 
Javascript :: react native delay input 
Javascript :: group by hash in jquery 
Javascript :: enquire js - simple media query library for Javascript 
Javascript :: react avoid spreading non-dom props across component 
Javascript :: react-select is unable to remove selected option after adding value props 
Javascript :: vue js key modifiers 
Javascript :: dev console with colored font 
Javascript :: Cannot GET /public/staffRegister in node.js 
Javascript :: como acrescentar item no array js 
Javascript :: var quotes 
Javascript :: raphael js rounded rectangle 
Javascript :: Arr::flatten() The Arr::flatten method flattens a multi-dimensional array into a single level array: 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =