# Troubleshooting

## Hook error: useLoaderStates must be used within LoaderProvider

Cause:
- A component called useLoaderStates outside LoaderProvider.

Fix:
- Ensure your app root wraps all relevant components in LoaderProvider.

## Loader never stops

Cause:
- registerLoader called without a matching removeLoader.

Fix:
- Always pair register/remove in try/finally.
- Prefer withPageLoader and withKeyLoader wrappers to avoid this issue.

## Button remains disabled after API failure

Cause:
- Custom code swallowed an error and did not run cleanup.

Fix:
- Use withKeyLoader("key", () => promise) since cleanup runs in finally.

## Cannot track multiple parallel operations properly

Cause:
- Reusing the same key for unrelated operations may merge states.

Fix:
- Use specific keys such as save-profile and upload-avatar.

## Does this support axios only?

No. It supports any Promise, including:
- axios
- fetch
- custom async functions

## How to test quickly

```bash
npm run build
```

Then consume package in a React app and verify:
- page-level loader turns on/off
- key-level button state toggles
- errors still clear loaders
