Skip to content

Commit a4721db

Browse files
committed
fix(ListItem): Fixed a crash on List.Item left prop
1 parent 4e68fdc commit a4721db

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/components/ListItem/ListItem.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@ 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;
22+
}
23+
24+
return () => props.left;
25+
}, [props.left]);
26+
1927
return (
2028
<List.Item
2129
{...rest as any}
2230
style={[
2331
selected && { backgroundColor: theme.palette.action.selected },
2432
props.style,
2533
]}
34+
left={leftNode}
2635
right={right ? rightNode : undefined}
2736
/>
2837
);

0 commit comments

Comments
 (0)