Skip to content

Add context hooks for metrics and sample manifest #1

@owtaylor

Description

@owtaylor

It's inefficient that the metrics and sample manifest are reloaded every time the user navigates to those pages - we really should be able to just load them once when the page is loaded.

To fix this, move web/src/utils/fetchMetrics to web/src/context/Metrics.tsx and make it export:

  • A hook 'useMetrics' that retrieves the metrics (or undefined before they are loaded)
  • A component MetricsProvider

Similarly, extract the sample manifest reading code from web/src/components/Samples.tsx to web/src/context/SampleManifest.tsx and make it export useSampleManifest() and SampleManifestProvider.

Then use these in App.tsx so that all the pages have access to the context, and modify page components appropriately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions