-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.js
45 lines (41 loc) · 1.05 KB
/
Button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, {useState} from 'react';
import {Text,View} from 'react-native';
import Touchable from './Touchable.js';
const Button = ({onPress, title}) => {
const [flash, setFlash] = useState(false);
const handleFlash = () => {
setFlash(true);
console.log("Flashing")
setTimeout(() => {
setFlash(false);
}, 200);
};
console.log("Flash is ",flash);
return (
<>
<Touchable
onPress={() => {
handleFlash();
onPress();
}}
style={{
padding: 8,
backgroundColor: flash ? 'black' : 'transparent',
borderWidth:2,
borderColor:'black',
borderRadius:8,
margin:8
}}>
<Text
style={{
backgroundColor: flash ? 'black' : 'transparent',
color: flash ? 'black' : 'transparent',
}}>
{title}
</Text>
</Touchable>
{flash && <View></View>}
</>
);
};
export default Button;