score:1
Accepted answer
When you want to show all the rollers, you can just call the function without any parameters. And then at the beginning of filterRollers function you can check if the parameter is undefined. If it is, just return all the data. If not, filter:
filterRollers(status) {
let list;
if(typeof status !== 'undefined'){
list = this.state.rollingState.filter(roll => {
return roll.isrolling === status
})
} else{
list = data.slice();
}
this.setState({
rollingData:list
})
}
Call the function like this, when you want to show all the rollers:
<button onClick={this.filterRollers()}> All </button>
Source: stackoverflow.com
Related Query
- Filter through a list to display data based on the status of user task
- How to show first letters of the firstname and lastname of the user in the list instead of image through json data using reactjs
- How to filter the data per row? Using a search input method, instantly update the rows based on what user inputs in react.js
- Filter through JSON data to create a filter based on the location of the job
- How to filter a list based on user input with ClojureScript and Om?
- Display an array item's data based on the radio button that's being selected
- Display mongoDB data in a table with most recent date at the top of list in ReactJS
- How do I filter a list of data by id for my react component to get the name of the object
- How to show the specified table row data based on the filter option in react js
- Loop through json object and display the data with React?
- Which is the best way to store a list of data in localStorage and display them when searched using a React app
- How do I filter the data returned by a map based on the key
- How to filter through cards based on the value using onChange when selected in a dropdown
- How to list data based on the selected option using react and typescript?
- How do I filter the data based on search input from array of objects in React, ES6
- How to filter the entire array based on user input using filter in JavaScript ?
- Update state from <select> tag using onChange and filter through list of categories to display blog posts from that category
- Created multi-Filtered buttons in React but the list won't display everytime I click on other filter button
- React: I have a component that renders user data and I want to display an error message underneath the section if there's an error rendering the data
- displaying data based on filter - react todo list
- How to loop through an array and display data within the object of that array, in react and javascript
- useEffect hook to filter through the JSON data and spit out new URL params to filter jobs (API)
- Arcgis builder custom widget to get specific field and value from user to filter the data
- How to loop through an object with key and associated array and filter the array based on value presence in another array
- How to filter the data array student based on the room using react hook form
- How do I filter through an array list and return results that match the filter parameter?
- Fetched data from external api,how to loop through the array and display values
- React - What's the best practice to refresh a list of data after adding a new element there?
- Why doesn't this select list render with the correct item selected based on the defaultValue
- Using Lodash debounce in React to prevent requesting data as long as the user is typing
More Query from same tag
- reactjs - render array separating contents from styles
- Filter array of objects through checkboxes
- React Form using Winterfell
- React if statement not showing result
- interface X extends ScrollElementProps<P> = P & {}
- Need to use react hooks to display a component based on button
- Warning: Encountered two children with the same key when implementing a Search Filter in React
- Why is using setState inside componentDidUpdate seen as a bad practice in React?
- Reference Item State Not Updated in React Redux on Save
- Parent state undefined in componentDidMount event of the child component
- not able to send request to express server using axios
- Cannot read property 'query' of null in react js
- Formik radio box not selectable
- Error: Request failed with status code 401 axios in React JS
- How should I update both array and <ul> at the same time using react hooks?
- Proper way of Installing ESlint with Prettier in a React Project
- Removal of AccordianDetails component from DOM on collapse of material-ui Accordian
- How to connect to class component without passing props typescript
- Iterate on JSON and add buttons in React
- How do you set the state of an array using useState?
- DHX Spreadsheet - Unable to select from Column A to D
- Access Data Dynamically in React
- Changing div text value by clicking on a li item
- React Date Picker color effect on hover and set date range
- React: How can I use {props.children} in two layouts of the App structure
- VScode messes JSX format (beautify)
- ReactJS - If Object Has Length
- How can i add objects into array using reducer
- REACT: Early return, Rendered fewer hooks than expected
- Server side rendering issue with routes importing