So, here is my App
component:
const App = () => {
const [lang, setLang] = useState("en");
return (
<IntlProvider
locale={lang}
key={lang}
messages={lang == "en" ? englishMessages : arabicMessages}
>
<AppBar>
<LangSwitch
checked={lang == "en"}
onChange={() => setLang(lang == "en" ? "ar" : "en")}
></LangSwitch>
</AppBar>
<Game />
</IntlProvider>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
and, this is my Game
component:
const Game = ()=>
(<div direction = "???">
I want to set direction to ltr if current locale is 'en' other wise to 'rtl'
</div>)
How can I read the current value of locale
-set in the parent component of IntlProvider
- inside child component of Game
and set the property direction
accordingly?