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

allow useQuery to filter or sort a collection by using a callback #5513

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

takameyer
Copy link
Contributor

What, How & Why?

This adds the ability to filter and sort the return value of useQuery, before it arrives in the component. This ensures that filtered and sorted are not called again when useQuery triggers a re-render.

This closes #5471

☑️ ToDos

  • 📝 Changelog entry
  • 📝 Compatibility label is updated or copied from previous entry
  • 📝 Update COMPATIBILITY.md
  • 🚦 Tests
  • 🔀 Executed flexible sync tests locally if modifying flexible sync
  • 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • 📱 Check the React Native/other sample apps work if necessary
  • 📝 Public documentation PR created or is not necessary
  • 💥 Breaking label has been applied or is not necessary

If this PR adds or changes public API's:

  • typescript definitions file is updated
  • jsdoc files updated

Copy link
Contributor

@elle-j elle-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, added minor things 👍

example/app/AppSync.tsx Outdated Show resolved Hide resolved
example/app/components/TaskManager.tsx Outdated Show resolved Hide resolved
packages/realm-react/CHANGELOG.md Outdated Show resolved Hide resolved
packages/realm-react/README.md Outdated Show resolved Hide resolved
levipro and others added 2 commits April 5, 2023 10:57
)

* allow useQuery to filter or sort a collection by using a callback method that gets momoized based on the dependency array

* cleanup based on comments

* add comment about 'queryCallback'

* update documentation

* change to useCallback

* cleanup comment

Expand on the useQuery PR

* Add a working example
* Fix a bug in rerendering
* Give credit to contributor
* Add example code

Update tsdoc
@takameyer takameyer force-pushed the andrew/realm-react/useQueryParams branch from eebf281 to cd53557 Compare April 5, 2023 08:57
takameyer and others added 2 commits April 5, 2023 11:46
Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
@takameyer takameyer merged commit 1c7f11c into main Apr 11, 2023
@takameyer takameyer deleted the andrew/realm-react/useQueryParams branch April 11, 2023 18:24
@takameyer
Copy link
Contributor Author

Merging this, but up for retrospective comments later.

papafe added a commit that referenced this pull request Apr 13, 2023
* main: (41 commits)
  allow useQuery to filter or sort a collection by using a callback (#5513)
  Fix `realm.create` types and 'requiredProperties' on Realm.Object constructor (#5697)
  Fix return type of `App.allUsers` (#5708)
  Removed renamed file
  Remove console.log
  Fix README instructions and bump version
  Bump template versions
  Update Templates (#5702)
  Moved "submodules" wireit task to "postinstall"
  Set up typedoc for realm-react, realm-web (#5709)
  Prepare for vNext (#5711)
  Prepare for 12.0.0-alpha.2 (#5707)
  Build iOS prebuilds in release by default (#5710)
  Use the event.sender as assignee when preparing release
  Updated prepare release workflow to print PR url in summary
  Fixing lint error
  fix the template app links (#5701)
  Expose `Sync` as named export (#5705)
  Enable all tests after bad rebase (#5595)
  Clear test state flag (#5689)
  ...

# Conflicts:
#	packages/realm/src/Realm.ts
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add argument to useQuery to allow result to be filtered and sorted
3 participants