feat: Application intl context provider.

This commit is contained in:
a.bouhuolia
2021-07-27 02:40:45 +02:00
parent 45ee031df1
commit 3da7b53f5e
3 changed files with 40 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
import React, { createContext } from 'react';
const AppIntlContext = createContext();
/**
* Application intl provider.
*/
function AppIntlProvider({ currentLocale, isRTL, children }) {
const provider = {
currentLocale,
isRTL,
isLTR: !isRTL,
};
return (
<AppIntlContext.Provider value={provider}>
{children}
</AppIntlContext.Provider>
);
}
const useAppIntlContext = () => React.useContext(AppIntlContext);
export { AppIntlProvider, useAppIntlContext };