UNPKG

@ramses-superapp/ramses-ui

Version:
20 lines (19 loc) 775 B
"use strict"; import { useMemo } from 'react'; import { StyleSheet } from 'react-native'; import { useTheme } from "./ThemeProvider.js"; /** * useStyles - User-friendly hook for theme-aware, optionally dynamic styles. * @param styleFactory - (theme, props) => style object * @param props - Optional dependency object (state/props) * @returns Memoized StyleSheet object */ export function useStyles(styleFactory, props) { const theme = useTheme(); // Memoize styles based on theme and props return useMemo(() => StyleSheet.create(styleFactory(theme, props ?? {})), // Spread props for shallow dependency tracking // eslint-disable-next-line react-hooks/exhaustive-deps [theme, ...(props ? Object.values(props) : [])]); } //# sourceMappingURL=useStyles.js.map