react-garden
Version:
React + TypeScript + ThreeJS app using Material UI on NextJS, Apollo Client, GraphQL + WordPress REST APIs, for ThreeD web development.. a part of the threed.ai code family.
31 lines (24 loc) • 648 B
JavaScript
// ** React Imports
import { useEffect } from 'react'
// ** Emotion Imports
import createCache from '@emotion/cache'
import { CacheProvider } from '@emotion/react'
// ** RTL Plugin
import stylisRTLPlugin from 'stylis-plugin-rtl'
const styleCache = () =>
createCache({
key: 'rtl',
prepend: true,
stylisPlugins: [stylisRTLPlugin]
})
const Direction = props => {
const { children, direction } = props
useEffect(() => {
document.dir = direction
}, [direction])
if (direction === 'rtl') {
return <CacheProvider value={styleCache()}>{children}</CacheProvider>
}
return <>{children}</>
}
export default Direction