Skip to content

Add Render Props Pattern Support to LocaleSwitcher #1085

Open

Description

@maxprilutskiy

Parent Issue

Subtask of #1083

Dependencies

⚠️ Requires #1084 completed first

Problem

No way to customize LocaleSwitcher UI without cloning entire component.

Requirements

1. Add Render Props Interface

export type LocaleSwitcherRenderProps = {
  currentLocale: string;
  locales: LocaleConfig[];
  setLocale: (locale: string) => void;
  isChanging: boolean;
};

2. Add Children Function Support

children?: (props: LocaleSwitcherRenderProps) => React.ReactNode;

3. Add Props

onChange?: (locale: string) => void;
autoReload?: boolean; // default: true
cookieName?: string;
cookieOptions?: CookieAttributes;

4. Enhance Cookie Utilities

export function getLocaleFromCookies(cookieName?: string): string;
export function setLocaleInCookies(
  locale: string, 
  cookieName?: string, 
  options?: CookieAttributes
): void;

Acceptance Criteria

  • children function receives correct props
  • isChanging shows true during locale changes
  • onChange callback fires before cookie/reload
  • autoReload: false prevents page reload
  • Custom cookie names work
  • Enhanced utilities exported in index.ts
  • All existing usage unchanged

Tests Required

  • Render props receive correct data
  • Loading states during changes
  • Custom onChange callbacks
  • autoReload behavior
  • Cookie customization

Activity

  1. realvishalrana commented on Oct 29, 2025

    @realvishalrana

    @maxprilutskiy can i work on this issue

  2. nnandan25 commented on Nov 7, 2025

    @nnandan25

    Hi @maxprilutskiy ,
    I'm starting my open-source journey and would like to contribute to this issue. Could you please assign it to me if no one else is currently working on it?

    Thank you!

  3. imsarang commented on Mar 14, 2026

    @imsarang

    Hi @sumitsaurabh927 , can you assign me this issue
    i can see no PR has been raised for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions