Open NoodleOfDeath opened 1 year ago
Would also be nice if the text
prop could be a function that returns a string
This is the test code I was using. All of my items have identical menu items except for onPress
. If you remove the ability to supply your own unique key, pressing and holding any of the items results in an alert message for whatever button you pressed first, no matter which button you press and hold:
import React from 'react';
import {
SafeAreaView,
Text,
View,
} from 'react-native';
import { HoldItem } from 'react-native-hold-menu';
function Test() {
const titles = ['one', 'two', 'three'];
return (
<View style={ { rowGap: 10 } }>
{titles.map((title) => (
<HoldItem
key={ title }
items={ [{
key: title,
onPress: function test() {
alert(title);
},
text: 'share',
}] }>
<Text style={ {
backgroundColor: '#eee',
padding: 10,
} }>
{title}
</Text>
</HoldItem>
))}
</View>
);
}
export function TestScreen() {
return (
<SafeAreaView style={ { flex: 1 } }>
<View style={ { padding: 24 } }>
<Test />
</View>
</SafeAreaView>
);
}
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch
react-native-hold-menu@0.1.6
for the project I'm working on.The following fixes what is happening in the below screen recording:
https://github.com/enesozturk/react-native-hold-menu/assets/14790443/c129af38-b9ae-428e-b811-0449f014d8e7
Here is the diff that solved my problem (https://github.com/enesozturk/react-native-hold-menu/issues/105):
Then in your code you will need to specify unique keys that react to whenever you want the item to be rerendered like this:
This issue body was partially generated by patch-package.