Bump @types/react to ^18 and adjust types (#889)
This commit is contained in:
parent
180697b66b
commit
9b19a95e63
15 changed files with 65 additions and 29 deletions
|
@ -6,6 +6,7 @@ import {
|
|||
TextStyle,
|
||||
Pressable,
|
||||
ViewStyle,
|
||||
PressableStateCallbackType,
|
||||
} from 'react-native'
|
||||
import {Text} from '../text/Text'
|
||||
import {useTheme} from 'lib/ThemeContext'
|
||||
|
@ -26,6 +27,14 @@ export type ButtonType =
|
|||
| 'secondary-light'
|
||||
| 'default-light'
|
||||
|
||||
// Augment type for react-native-web (see https://github.com/necolas/react-native-web/issues/1684#issuecomment-766451866)
|
||||
declare module 'react-native' {
|
||||
interface PressableStateCallbackType {
|
||||
hovered?: boolean
|
||||
focused?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Enforce that button always has a label
|
||||
export function Button({
|
||||
type = 'primary',
|
||||
|
@ -139,7 +148,7 @@ export function Button({
|
|||
)
|
||||
|
||||
const getStyle = React.useCallback(
|
||||
state => {
|
||||
(state: PressableStateCallbackType) => {
|
||||
const arr = [typeOuterStyle, styles.outer, style]
|
||||
if (state.pressed) {
|
||||
arr.push({opacity: 0.6})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue