Created
October 27, 2022 22:35
-
-
Save zivc/e0f3ee2af718bc72ad4f2e8e5a32ef7b to your computer and use it in GitHub Desktop.
Want to make a higher/lower order component based on NativeBase but don't want to change a whole bunch of shit or register your component via NativeBase? Cba to register a variant? Or a theme? Or some other nuance? native-base v.3.4.19 - heres a dumb reusable ContactUsButton component
This file contains 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 { useToken } from "native-base"; | |
export default function useIconSizeInPixels(nativeBaseIconSize) { | |
const iconSize = useToken("components.Icon.sizes", nativeBaseIconSize); | |
const pxSize = useToken("sizes", iconSize); | |
return pxSize; | |
} |
This file contains 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 defaultsDeep from "lodash.defaultsdeep"; | |
import { useThemeProps } from "native-base"; | |
export default function useNativeBaseProps(component, inheritedProps = {}, defaultProps = {}) { | |
return useThemeProps(component, defaultsDeep({}, inheritedProps, defaultProps)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment