Created
August 18, 2021 03:48
-
-
Save Misaka-0x447f/69ef54aaf7689ad1554f98aada28eaaf to your computer and use it in GitHub Desktop.
react native 创建基于原生组件的透明组件
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
// 合并的方式不是给 style 传一个可能带 function 的 array,而是给 style 传一个返回值一定不带 function 的 (whatever: any) => unknown[] | |
export const PressableWithFeedback: React.FC<PressableProps> = props => { | |
return ( | |
<Pressable | |
{...props} | |
style={args => [ | |
isFunction(props.style) ? props.style(args) : props.style, | |
{ | |
backgroundColor: args.pressed ? 'white' : 'transparent', | |
}, | |
]} | |
/> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment