Skip to content

No re-render when locale changes, please add multi-locale example #65

@MaxDonchenko

Description

@MaxDonchenko

Related to https://github.com/gtournie/redux-form-validators/blob/master/examples/src/index.js#L25.

I'm working with Redux-Saga and it watches for "CHANGE_LOCALE" action:

// saga
export function* changeLocaleSaga(action: routines.setLocaleAction) {
  yield call(LocaleService.configureReduxFormValiators, action.payload);
}

yield all([
  takeEvery(routines.CHANGE_LOCALE, changeLocaleSaga),
]);

And in Locale Service I mutate the Validators:

// Locale.service
function configureReduxFormValiators(locale: ISupportedLocale) {
  const messages = getTranslationsByLocale(locale);

  Validators.messages = {
    ...Validators.messages,
    email: messages['component.field.error.isNotValidEmail'],
  };
}

export const LocaleService = {
  // getTranslationsByLocale,
  // getSupportedLocaleByLocale,
  configureReduxFormValiators,
};

BUT the problem here that Validators mutation doesn't tell React to re-render.

Please advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions