I want to call SingleCard
child component methods in renderHiddenItem
. I have assigned different ref name for each renderItem
. But when I call this.name, it is undefined
. Anything is wrong in this code? How can I achieve this?
<SwipeListView
data={this.state.listViewData}
renderItem={(data, i) => {
const name = 'childRef'+i
return (
<SingleCard
ref={component => this.name = component}
itm={data.item}
/>
);
}}
renderHiddenItem={(data, i) => {
const name = 'childRef'+i
return (
<TouchableOpacity onPress={ () => console.log(this.name)}>
<Text> h </Text>
</TouchableOpacity>
);
}
}}
/>
Update:
I want to trigger some action which is written in the singleCard component. Need to call that in renderHiddenItem
.
Like this:
this.childRef0.someMethod
this.childRef1.someMethod