Function useSchemasByState

  • Hook for fetching and filtering schemas by a specific state.

    This hook extends the useSchemas hook by adding a filtering layer to only return schemas that match a specific state. It passes additional parameters to useSchemas and refines the schema list based on the provided state.

    Parameters

    • state: string

      The specific state to filter schemas by.

    • Optional params: {
          [key: string]: any;
      }

      Optional parameters for customizing the schema fetch behavior (e.g., page, limit, or other query parameters).

      • [key: string]: any

    Returns {
        currentPage: number;
        fetchMore: SchemaFetchMoreMethod;
        fetched: boolean;
        hasMore: boolean;
        refresh: SchemasFetchMethod;
        schemas: SchemaExtendedType[];
    }

    Returns the filtered schemas and other state management methods from UseSchemasReturn.

    Example

    import { useSchemasByState } from 'react-playmakers';

    const MyComponent = () => {
    const { schemas, fetched, fetchMore, refresh } = useSchemasByState('active', { limit: 10 });

    useEffect(() => {
    if (!fetched) {
    console.log('Fetching schemas...');
    }
    }, [fetched]);

    return (
    <div>
    <h1>Active Schemas</h1>
    <ul>
    {schemas.map(schema => (
    <li key={schema.id}>{schema.name}</li>
    ))}
    </ul>
    {fetchMore && <button onClick={fetchMore}>Load More</button>}
    <button onClick={refresh}>Refresh</button>
    </div>
    );
    };

Generated using TypeDoc