Created
August 9, 2021 17:08
-
-
Save pffigueiredo/1ae6121c1b1505c5212c14db27d2a03d to your computer and use it in GitHub Desktop.
_app file using stylis plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { AppProps } from 'next/app'; | |
import { StyleSheetManager } from 'styled-components'; | |
import { StylisPlugin } from 'styled-components'; | |
import stylisRTLPlugin from 'stylis-plugin-rtl'; | |
import { useTranslation } from 'react-i18next'; | |
const App = (props: AppProps): JSX.Element => { | |
const { Component, pageProps, router } = props; | |
const { locale } = router; | |
const { i18n } = useTranslation(); | |
// Get direction based on locale | |
const direction = i18n.dir(locale); | |
return ( | |
<StyleSheetManager | |
stylisPlugins={ | |
direction === 'rtl' ? [stylisRTLPlugin as unknown as StylisPlugin] : [] | |
} | |
> | |
<Component {...pageProps} /> | |
</StyleSheetManager> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment