@@ -25,13 +25,14 @@ function useCsrContent<I, F>(
2525 fallback : fallbackContent ,
2626 initial : initialContent ,
2727 staleWhileLoading = false ,
28+ preferredLocale,
2829 ...fetchOptions
2930 } = options ;
3031
31- const preferredLocale = normalizePreferredLocale ( fetchOptions . preferredLocale ) ;
32+ const normalizedLocale = normalizePreferredLocale ( preferredLocale ) ;
3233 const defaultContent = useMemo (
33- ( ) => getSlotContent ( id , preferredLocale ) as SlotContent | null ?? undefined ,
34- [ id , preferredLocale ] ,
34+ ( ) => getSlotContent ( id , normalizedLocale ) as SlotContent | null ?? undefined ,
35+ [ id , normalizedLocale ] ,
3536 ) ;
3637 const fallback = fallbackContent === undefined ? defaultContent : fallbackContent ;
3738 const [ initial , setInitial ] = useState < SlotContent | I | F | undefined > (
@@ -44,13 +45,13 @@ function useCsrContent<I, F>(
4445 cacheKey : hash (
4546 `useContent:${ cacheKey ?? '' } `
4647 + `:${ id } `
47- + `:${ preferredLocale ?? '' } `
48+ + `:${ normalizedLocale ?? '' } `
4849 + `:${ JSON . stringify ( fetchOptions . attributes ?? { } ) } ` ,
4950 ) ,
5051 loader : ( ) => croct . fetch ( id , {
5152 ...fetchOptions ,
52- preferredLocale : preferredLocale ,
53- fallback : fallback ,
53+ ... ( normalizedLocale !== undefined ? { preferredLocale : normalizedLocale } : { } ) ,
54+ ... ( fallback !== undefined ? { fallback : fallback } : { } ) ,
5455 } ) . then ( ( { content} ) => content ) ,
5556 initial : initial ,
5657 expiration : expiration ,
0 commit comments