score:0
Accepted answer
i solved this by doing the following
filteredpayload: state. mypayload.filter(item => {
switch (item.type) {
case 'building':
return (
item.name.tolowercase().match(value)
|| item.country.tolowercase().match(value)
|| item.state.tolowercase().match(value)
);
case 'student':
case 'teacher':
return (
item.name.tolowercase().match(value)
|| item.age.tolowercase().match(value)
|| item.height.tolowercase().match(value)
);
}
return item;
}),
thank you all for helping out ^_^
score:2
you could just search in the values of the object, so you do not really need to care about the key names.
filteredpayload: state.mypayload.filter(item => (
object.values(item).some(objvalue => (
objvalue.tolowercase().match(value)
))
))
Source: stackoverflow.com
Related Query
- React filter payload arrays
- React filter two arrays with if statement
- React javascript two arrays of objects,I want to find and filter by key, and the result of this, I want to count by another key
- React redux how to compare two obj arrays with filter
- Filter results from nested Arrays (small React application)
- Search Filter with React Native on FlatList
- how to create React search filter for search multiple object key values
- Best way to filter table in React
- How do I iterate nested arrays in a React component?
- Right way to clone objects / arrays during setState in React
- React Native Navigation Error: The action navigate with payload {"name": 192.168.100.189:19000", "params":{}} was not handled by any navigator
- check if two arrays contain identical objects - react componentDidUpdate
- Filter multiple values in React
- Use Buttons to trigger filter function on react-table in React
- Filter out children of a React component
- AngularJS filter in React Component
- React JS: Filter an array by a string
- Filter Array of Objects based on input field in React
- React filter items with dropdown
- How to reset filter fields in React Table?
- Using React Date Range picker to filter a React table
- arrays vs key value pairs (Map/Object) in React
- React - filter by object property
- AngularJS date filter in React
- Filter The List Using Multiple CheckBoxes in React Js
- How to fix a React search filter that doesn't update on backspace
- Pass payload in GET request React fetch
- React Typescript: Antd Table filter
- React multiple filter dropdowns
- react native how to filter data with some key object on json
More Query from same tag
- React: Function call portal does not contain target
- How to put data in fields when updating?
- How to get only the specific variation data to be display in react.js
- TypeError: can't define property "current": Object is not extensible
- Drag Files & Select Files to React
- How to format and display JSON data using Array.map in Reactjs?
- How to use useEffect hook with the dependency list as a specific field in an array of objects?
- How to add Font Awesome into React.js?
- Iterating through JSON array, accessing name for output and Id to set className
- Can I host the same react app at two different paths on my website?
- React performing slow on extreme socket updates
- How to clean up subscriptions in react components? (Hooks)
- Displaying only 3 day of a week view of fullcalendar in React
- DraftJS: nextEditorState.getDirectionMap is not a function
- React JS onChange Event is not triggered
- Change <svg:path/> Opacity on MouseOver
- Conditional rendering decimal codes in JSX in React.js
- How to add each element in a list to a new row in React table
- Unable to use React context
- How to avoid recursive dependencies in useEffect hook
- How do I setup react-router clean URL's with IIS?
- RefluxJS "single" store?
- Storybook 6, use module paths?
- Fetch API in React for JSON file: Uncaught (in promise) SyntaxError: Unexpected token � in JSON at position 0
- Why do I have to wrap the functions of my onClick attributes in anonymous functions in React?
- Passing several arguments into react component
- I18nManager.forceRTL doesn't applies changes in first app load
- Why the whole page is re-rendering when i change the range slider in react?
- align a text to right with ellipsis and button (react-js)
- Code works on site, not on CodePen: Uncaught error '<'