import * as React from 'react' ; import { ThemeContext } from '@emotion/core' ; import { EmotionCanvasTheme , ContentDirection , PartialEmotionCanvasTheme } from './types' ; function useDefaultTheme < T , C > ( theme , config , fn ) { return theme || fn ( config ) ; } example export const useIsRTL = ( partialTheme ? ) => { const theme = useDefaultTheme ( partialTheme , ThemeContext , React . useContext ) as EmotionCanvasTheme ; return ( theme && theme . canvas && theme . canvas . direction ) === ContentDirection . RTL ; } ;