# Measurements

### Description

Components for body measurements such as weight.

## WeightProgress

### Description

A summary of the member's weight: their current weight and their goal. Tapping it opens a sheet where the member enters a new weight or goes on to edit their goal.

### Basic usage

```tsx
import { useCallback, useEffect, useState } from 'react';
import { BodyComposition, useMiriApp, WeightProgress } from '@miri-ai/miri-react-native';

function WeightCard() {
  const { getWeightProgress, getBodyComposition } = useMiriApp();
  const [weightProgress, setWeightProgress] = useState<
    Awaited<ReturnType<typeof getWeightProgress>>
  >({ weightGoal: null, weightTracking: null });
  const [bodyComposition, setBodyComposition] = useState<BodyComposition | null>(null);
  const [isLoading, setIsLoading] = useState(true);

  const refresh = useCallback(async () => {
    setWeightProgress(await getWeightProgress());
    setBodyComposition(await getBodyComposition());
    setIsLoading(false);
  }, [getWeightProgress, getBodyComposition]);

  useEffect(() => {
    refresh();
  }, [refresh]);

  return (
    <WeightProgress
      weightProgress={weightProgress}
      bodyComposition={bodyComposition}
      isLoading={isLoading}
      onUpdateWeightTracking={refresh}
    />
  );
}
```

### Props

| Prop | Type | Description |
| :--- | :--- | :--- |
| `weightProgress` _(required)_ | `{ weightGoal: PlanArtifactWeight \| null; weightTracking: WeightTracking \| null }` | The result of `getWeightProgress`. |
| `bodyComposition` _(required)_ | `BodyComposition \| null` | The result of `getBodyComposition`. Required by the props type, which `WeightProgress` shares with the other body-stats components; `WeightProgress` itself shows weight only. |
| `isLoading` | `boolean` | If `true`, shows the loading state. |
| `onUpdateWeightTracking` | `(weightGoal: PlanArtifactWeight) => Promise<void>` | Called after the member saves a new weight, with the saved weight entry (despite the parameter name). |
| `onUpdateWeightGoal` | `() => void` | Called when the member chooses to edit their weight goal. We recommend opening the `UserSettings` component, where the goal is edited. |
