I am trying to find solution to toggle between ltr and rtl view in react native expo

224 Views Asked by At

I am trying to find solution to toggle between ltr and rtl view in react native expo. I have tried this solution:

import * as Updates from "expo-updates";

import {
  I18nManager,
} from "react-native";
// i18 is intialised object of i18next

const changeLanguage = (value) => {
    i18n
      .changeLanguage(value)
      .then(() => {
        setLanguage(value);
        if (value === "ar") {
          if (true && Platform.OS !== "web") {
            I18nManager.allowRTL(true);
            I18nManager.forceRTL(true);
            Updates.reloadAsync();
          }
        } else {
          I18nManager.allowRTL(false);
          I18nManager.forceRTL(false);
          Updates.reloadAsync();
        }
      })
      .catch((err) => console.log(err));
  };

but Updates.reloadAsync(); results in an error:

Error: You cannot use the Updates module in development mode in a production app. To test manual updates, publish your project using expo publish and open the published version in this development client.

So rtl to ltr and ltr to rtl not working.

I have also tried expo publish then also ltr to rtl not working. please give me a solution for that. can you provide me alternative solution for reloading app or if anything wrong i am following in my code then please help me with that.

1

There are 1 best solutions below

0
On

As the error message says, you can't use Updates.reloadAsync() in development; instead, you can use DevSettings.reload() to reload the app.