UNPKG

react-native-material-elements

Version:

React native material elements is a sophisticated UI library crafted to enhance your React Native development workflow. Designed for simplicity and elegance, nex-ui provides a rich collection of components and utilities to effortlessly create polished mob

26 lines (21 loc) 683 B
import React from 'react'; import { StyledProps, StyleLike } from '../libraries/style/styleTypes'; export const useRestyle = <T>(props: T & StyledProps) => { function isValidStyle<U>(value: U) { if (value === undefined || value === null || React.isValidElement(value)) { return false; } return typeof value === 'string' || typeof value === 'number'; } const getStyleFromProps = () => { const result: Record<string, StyleLike> = {}; for (const key in props) { const value = props[key as keyof StyledProps]; if (isValidStyle(value)) { result[key] = value; } } return result; }; return { getStyleFromProps }; };