Optional
deps: DependencyListAn array of dependencies that will be passed to React.useMemo
a collection of realm objects or an empty array
// Return all collection items
const collection = useQuery({ type: Object });
// Return all collection items sorted by name and filtered by category
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
}, [category]);
// Return all collection items sorted by name and filtered by category, triggering re-renders only if "name" changes
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
keyPaths: ["name"]
}, [category]);
Returns a Realm.Collection of Realm.Objects from a given type. The hook will update on any changes to any object in the collection and return an empty array if the collection is empty.
The result of this can be consumed directly by the data
argument of any React Native
VirtualizedList or FlatList. If the component used for the list's renderItem
prop is React.Memoized,
then only the modified object will re-render.
Optional
deps: DependencyListAn array of dependencies that will be passed to React.useMemo
a collection of realm objects or an empty array
// Return all collection items
const collection = useQuery({ type: Object });
// Return all collection items sorted by name and filtered by category
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
}, [category]);
// Return all collection items sorted by name and filtered by category, triggering re-renders only if "name" changes
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
keyPaths: ["name"]
}, [category]);
Returns a Realm.Collection of Realm.Objects from a given type. The hook will update on any changes to any object in the collection and return an empty array if the collection is empty.
The result of this can be consumed directly by the data
argument of any React Native
VirtualizedList or FlatList. If the component used for the list's renderItem
prop is React.Memoized,
then only the modified object will re-render.
a collection of realm objects or an empty array
// Return all collection items
const collection = useQuery({ type: Object });
// Return all collection items sorted by name and filtered by category
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
}, [category]);
// Return all collection items sorted by name and filtered by category, triggering re-renders only if "name" changes
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
keyPaths: ["name"]
}, [category]);
Returns a Realm.Collection of Realm.Objects from a given type. The hook will update on any changes to any object in the collection and return an empty array if the collection is empty.
The result of this can be consumed directly by the data
argument of any React Native
VirtualizedList or FlatList. If the component used for the list's renderItem
prop is React.Memoized,
then only the modified object will re-render.
a collection of realm objects or an empty array
// Return all collection items
const collection = useQuery({ type: Object });
// Return all collection items sorted by name and filtered by category
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
}, [category]);
// Return all collection items sorted by name and filtered by category, triggering re-renders only if "name" changes
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
keyPaths: ["name"]
}, [category]);
Returns a Realm.Collection of Realm.Objects from a given type. The hook will update on any changes to any object in the collection and return an empty array if the collection is empty.
The result of this can be consumed directly by the data
argument of any React Native
VirtualizedList or FlatList. If the component used for the list's renderItem
prop is React.Memoized,
then only the modified object will re-render.
Optional
query: QueryCallback<T>Optional
deps: DependencyListAn array of dependencies that will be passed to React.useMemo
a collection of realm objects or an empty array
// Return all collection items
const collection = useQuery({ type: Object });
// Return all collection items sorted by name and filtered by category
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
}, [category]);
// Return all collection items sorted by name and filtered by category, triggering re-renders only if "name" changes
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
keyPaths: ["name"]
}, [category]);
Returns a Realm.Collection of Realm.Objects from a given type. The hook will update on any changes to any object in the collection and return an empty array if the collection is empty.
The result of this can be consumed directly by the data
argument of any React Native
VirtualizedList or FlatList. If the component used for the list's renderItem
prop is React.Memoized,
then only the modified object will re-render.
a collection of realm objects or an empty array
// Return all collection items
const collection = useQuery({ type: Object });
// Return all collection items sorted by name and filtered by category
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
}, [category]);
// Return all collection items sorted by name and filtered by category, triggering re-renders only if "name" changes
const filteredAndSorted = useQuery({
type: Object,
query: (collection) => collection.filtered('category == $0',category).sorted('name'),
keyPaths: ["name"]
}, [category]);
Generated using TypeDoc
Returns a Realm.Collection of Realm.Objects from a given type. The hook will update on any changes to any object in the collection and return an empty array if the collection is empty.
The result of this can be consumed directly by the
data
argument of any React Native VirtualizedList or FlatList. If the component used for the list'srenderItem
prop is React.Memoized, then only the modified object will re-render.