In the list component, how to implement the component to change the number of displayed results

I was thinking of creating a simple component using Select and a list of the results that should be displayed.

After reading the code, this seems impossible, because if I change the URL, the update starts componentWillReceiveProps, and this method does not check the changeperPage

Changing the prop perPageof the List component does not work either because List uses this option only if the request does not already containperPage

Here is an example of what I want to do:

import { List } from "admin-on-rest";
class SourceList extends Component {
constructor(props) {
    super(props);
    this.state = {
        perPage: 10
    };
}

render() {
    return (
        <div>
            <Button
                onClick={() => {
                    this.setState({ perPage: 50 });
                }}
            />

            <List {...props} perPage={this.state.perPage}>
                ... Here would be the content of the list
            </List>
        </div>
    );
}
}
+4
source share

Source: https://habr.com/ru/post/1679561/


All Articles