N
N
Nikita Shchypylov2018-01-10 17:53:30
React
Nikita Shchypylov, 2018-01-10 17:53:30

A couple of questions about implementing filters in React?

Hello everyone, I need to implement several table filters:
1) I have a table with animal names. You need to make a checkbox for each animal. If the box is not active, then hide the element.
Solution: checkboxes have a special attribute. When clicking on a checkbox, we accept its attribute and give all elements with this class display: none?
2) Each animal has a price from 1 to 1000. You need to filter by price with a slider widget. That is, we select the price area from and to and filter the animals. I don't even know how to do this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-01-10
@rockon404

In a good way, you should have a request to the server with sorting, pagination, filtering and limit.
For each click on sorting, paginator or filter request. For example:
What you want to implement, at least, is unlikely to be used in a real application.
Learn to solve real problems.
And tricks with display: none , if possible, x react can not be used at all.
Even if you cannot yet implement a server with a database and a REST API. It would be more correct to store the filter state in the state of the component and issue an array with animals filtered by the filter parameters from the state to the reader. The filter has changed - a render has occurred. That's the whole task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question