Conditional Paging Options
Cannot Conditionally Select Options
-
Demo of the Issue
-
I want to conditionally set paging option based on the data length, but it is not working for me.
-
Details
Say I fetch a remote data. The data length is say an array with 3 elements. I don't want paging option. Say I fetch a remote data for another user, the data length is say an array with 150 elements, I want paging options with default pagingSize 50 and pageSizeOptions of 50, 100, 200.
When I use ternary conditionals, immediately executed functions, call whatever, the conditional format defaults the paging size to 5 (Five). But the dropdown has (50, 100, 200). On the console I get the following error:
Material-UI: You have provided an out-of-range value `5` for the select component.
Consider providing a value that matches one of the available options or ''.
The available values are `50`, `100`, `200`.
The answer is: I was just passing
pageSize:50,
pageSizeOptions: [50,100,200]
}```
but I did not pass `paging: true` with it,
so the better option was:
``` const options = {
paging: fetchedData.length > 49,
pageSize: 50,
pageSizeOptions: [50, 100, 200]
}