Skip to content

Commit 07052c6

Browse files
authored
Feat/ add customElement prop to Drawer (#1402)
1 parent af9cb1d commit 07052c6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

generatedTypes/components/drawer/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PureComponent, RefObject } from 'react';
1+
import React, { PureComponent, ReactNode, RefObject } from 'react';
22
import { Animated, ViewStyle, TextStyle } from 'react-native';
33
import Swipeable, { SwipeableProps } from './Swipeable';
44
interface ItemProps {
@@ -10,6 +10,7 @@ interface ItemProps {
1010
keepOpen?: boolean;
1111
style?: ViewStyle;
1212
testID?: string;
13+
customElement?: ReactNode;
1314
}
1415
interface Props {
1516
/**

src/components/drawer/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import React, {PureComponent, RefObject} from 'react';
2+
import React, {PureComponent, ReactNode, RefObject} from 'react';
33
import memoize from 'memoize-one';
44
import {Animated, Easing, StyleSheet, ViewStyle, TextStyle, AccessibilityActionEvent} from 'react-native';
55
import {RectButton} from 'react-native-gesture-handler';
@@ -23,6 +23,7 @@ interface ItemProps {
2323
keepOpen?: boolean;
2424
style?: ViewStyle;
2525
testID?: string;
26+
customElement?: ReactNode;
2627
}
2728

2829
interface Props {
@@ -347,7 +348,8 @@ class Drawer extends PureComponent<Props> {
347348
]}
348349
onPress={() => this.onActionPress(item)}
349350
>
350-
{item.icon && (
351+
{item.customElement}
352+
{!item.customElement && item.icon && (
351353
<Animated.Image
352354
source={item.icon}
353355
style={[
@@ -362,7 +364,7 @@ class Drawer extends PureComponent<Props> {
362364
]}
363365
/>
364366
)}
365-
{item.text && (
367+
{!item.customElement && item.text && (
366368
<Animated.Text
367369
style={[
368370
styles.actionText,

0 commit comments

Comments
 (0)