Skip to content

Deep props make Query send request on every update #3174

Description

@PPierzc

What you were expecting:
The Query component should send a request on update only when the props have changed.

What happened instead:
Sends request on every update

Steps to reproduce:
Create a deep payload object for the Query component.

Related code:

const payload = {
      id: record.id,
      target: 'author',
      sort: {
        order: 'DESC',
        field: 'createdAt'
      },
      pagination: {
        page: 1,
        perPage: 1
      }
}

return (
      <Query
        type='GET_MANY_REFERENCE'
        resource={constants.resources.posts}
        payload={payload}
      >
        {({ data, loading, error }) => {
          return <></>
      </Query>
)

Other information:
A solution could be to change shallowEqual in the Query's componentDidUpdate to deepEqual.

Environment

  • React-admin version: 2.9.0
  • Last version that did not exhibit the issue (if applicable): -
  • React version: 16.6.3
  • Browser: Google Chrome 73
  • Stack trace (in case of a JS error): -

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions