Skip to content

Commit c0b6beb

Browse files
committed
fix(ListItem): Fixed left & right props
1 parent a4721db commit c0b6beb

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎src/components/ListItem/ListItem.tsx‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { ListItemProps, View } from '@bluebase/components';
2-
import React, { useCallback } from 'react';
2+
import React, { useMemo } from 'react';
33
import { List } from 'react-native-paper';
44
import { useTheme } from '@bluebase/core';
55

66
export const ListItem = (props: ListItemProps) => {
7-
const { selected, right, ...rest } = props;
7+
const { selected, right, left, ...rest } = props;
88
const { theme } = useTheme();
99

10-
const rightNode = useCallback(() => (
10+
const rightNode = useMemo(() => !right ? right : () => (
1111
<View style={{
1212
justifyContent: 'center',
1313
padding: theme.spacing.unit
@@ -16,13 +16,18 @@ export const ListItem = (props: ListItemProps) => {
1616
</View>
1717
), [right, theme.spacing.unit]);
1818

19-
const leftNode = useCallback(() => {
20-
if (typeof props.left === 'function') {
21-
return props.left;
19+
const leftNode = useMemo(() => {
20+
21+
if (!left) {
22+
return null;
23+
}
24+
25+
if (typeof left === 'function') {
26+
return left;
2227
}
2328

24-
return () => props.left;
25-
}, [props.left]);
29+
return () => left;
30+
}, [left]);
2631

2732
return (
2833
<List.Item

0 commit comments

Comments
 (0)