함수 useQuery

  • 주어진 유형에서 Realm.ObjectRealm.Collection을 반환합니다. 후크는 컬렉션의 객체가 변경될 때마다 업데이트되고 컬렉션이 비어 있으면 빈 배열을 반환합니다.

    그 결과는 모든 React Native VirtualizedList 또는 FlatList의 data 인수에서 직접 사용할 수 있습니다. 목록의 renderItem 속성에 사용된 구성 요소가 React.Memoized인 경우 수정된 객체만 다시 렌더링됩니다.

    유형 매개변수

    • t

    매개변수

    • options: QueryHookOptions<T>
    • Optional deps: dependencyList

      React.useMemo에 전달될 종속성 배열입니다.

    반환 결과<T & 객체<T, 절대>>

    Realm 객체 컬렉션 또는 빈 배열

    예제

    // 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]);
  • 주어진 유형에서 Realm.ObjectRealm.Collection을 반환합니다. 후크는 컬렉션의 객체가 변경될 때마다 업데이트되고 컬렉션이 비어 있으면 빈 배열을 반환합니다.

    그 결과는 모든 React Native VirtualizedList 또는 FlatList의 data 인수에서 직접 사용할 수 있습니다. 목록의 renderItem 속성에 사용된 구성 요소가 React.Memoized인 경우 수정된 객체만 다시 렌더링됩니다.

    유형 매개변수

    • t 확장 개체<어떤, 절대로, t>

    매개변수

    반환 결과<T>

    Realm 객체 컬렉션 또는 빈 배열

    예제

    // 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]);
  • 주어진 유형에서 Realm.ObjectRealm.Collection을 반환합니다. 후크는 컬렉션의 객체가 변경될 때마다 업데이트되고 컬렉션이 비어 있으면 빈 배열을 반환합니다.

    그 결과는 모든 React Native VirtualizedList 또는 FlatList의 data 인수에서 직접 사용할 수 있습니다. 목록의 renderItem 속성에 사용된 구성 요소가 React.Memoized인 경우 수정된 객체만 다시 렌더링됩니다.

    유형 매개변수

    • t

    매개변수

    • type: 문자열

    반환 결과<T & 객체<T, 절대>>

    Realm 객체 컬렉션 또는 빈 배열

    예제

    // 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]);
  • 주어진 유형에서 Realm.ObjectRealm.Collection을 반환합니다. 후크는 컬렉션의 객체가 변경될 때마다 업데이트되고 컬렉션이 비어 있으면 빈 배열을 반환합니다.

    그 결과는 모든 React Native VirtualizedList 또는 FlatList의 data 인수에서 직접 사용할 수 있습니다. 목록의 renderItem 속성에 사용된 구성 요소가 React.Memoized인 경우 수정된 객체만 다시 렌더링됩니다.

    유형 매개변수

    • t 확장 개체<어떤, 절대로, t>

    매개변수

    • type: RealmClassType<T>

    반환 결과<T>

    Realm 객체 컬렉션 또는 빈 배열

    예제

    // 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]);
  • 주어진 유형에서 Realm.ObjectRealm.Collection을 반환합니다. 후크는 컬렉션의 객체가 변경될 때마다 업데이트되고 컬렉션이 비어 있으면 빈 배열을 반환합니다.

    그 결과는 모든 React Native VirtualizedList 또는 FlatList의 data 인수에서 직접 사용할 수 있습니다. 목록의 renderItem 속성에 사용된 구성 요소가 React.Memoized인 경우 수정된 객체만 다시 렌더링됩니다.

    유형 매개변수

    • t

    매개변수

    • type: 문자열
    • Optional query: QueryCallback<T>
    • Optional deps: dependencyList

      React.useMemo에 전달될 종속성 배열입니다.

    반환 결과<T & 객체<T, 절대>>

    Realm 객체 컬렉션 또는 빈 배열

    예제

    // 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]);
  • 주어진 유형에서 Realm.ObjectRealm.Collection을 반환합니다. 후크는 컬렉션의 객체가 변경될 때마다 업데이트되고 컬렉션이 비어 있으면 빈 배열을 반환합니다.

    그 결과는 모든 React Native VirtualizedList 또는 FlatList의 data 인수에서 직접 사용할 수 있습니다. 목록의 renderItem 속성에 사용된 구성 요소가 React.Memoized인 경우 수정된 객체만 다시 렌더링됩니다.

    유형 매개변수

    • t 확장 개체<어떤, 절대로, t>

    매개변수

    • type: RealmClassType<T>
    • Optional query: QueryCallback<T>
    • Optional deps: dependencyList

      React.useMemo에 전달될 종속성 배열입니다.

    반환 결과<T>

    Realm 객체 컬렉션 또는 빈 배열

    예제

    // 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]);

TypeDoc을 사용하여 생성됨