Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep props make Query send request on every update #3174

Closed
PPierzc opened this issue Apr 29, 2019 · 1 comment · Fixed by #3267
Closed

Deep props make Query send request on every update #3174

PPierzc opened this issue Apr 29, 2019 · 1 comment · Fixed by #3267
Labels

Comments

@PPierzc
Copy link
Contributor

PPierzc commented Apr 29, 2019

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): -
@PPierzc PPierzc changed the title Deep props make Query send endless requests Deep props make Query send request on every update Apr 29, 2019
@Kmaschta
Copy link
Contributor

Kmaschta commented Apr 29, 2019

Related to #3146

The Query component use a shallowEqual, is it on purpose @fzaninotto ?

!shallowEqual(prevProps.payload, this.props.payload) ||
!shallowEqual(prevProps.options, this.props.options)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants