Skip to content

Commit 0a814e6

Browse files
authored
docs: prevent headers function from always returning actionHeaders (#14088)
1 parent 733fd78 commit 0a814e6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
- bvangraafeiland
6767
- camthompson
6868
- CanRau
69+
- caprolactam
6970
- cassidoo
7071
- chaance
7172
- chasinhues

docs/how-to/headers.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ export async function loader({ params }: LoaderArgs) {
5555
Headers from loaders and actions are not sent automatically. You must explicitly return them from the `headers` export.
5656

5757
```tsx
58+
function hasAnyHeaders(headers: Headers): boolean {
59+
return [...headers].length > 0;
60+
}
61+
5862
export function headers({
5963
actionHeaders,
6064
loaderHeaders,
6165
}: HeadersArgs) {
62-
return actionHeaders ? actionHeaders : loaderHeaders;
66+
return hasAnyHeaders(actionHeaders) ? actionHeaders : loaderHeaders;
6367
}
6468
```
6569

0 commit comments

Comments
 (0)