I get `_this4.myfunc is not a function` calling this.myfunc() from onPress() of a TouchableHighlight in an item
See original GitHub issueI’ve got a carousel like this:
render() {
<Carousel
ref={(carousel) => { this._carousel = carousel; }}
renderItem={this._renderCarouselItem}
data={this.state.person.imagesList}
sliderWidth={this.state.viewport.width}
itemWidth={this.state.viewport.width}
>
</Carousel>
}
_renderCarouselItem({item, index}) {
return (
<TouchableHighlight key={item.key} onPress={() => this.setFullscreen(item.key)}>
<Image
source={{uri: item.uri}}
/>
</TouchableHighlight>
);
}
setFullscreen(index) {
...
}
The problem is I don’t know how to bind
to this
in _renderCarouselItem
function, since when pressing on an image I get a reddish _this4.setFullscreen is not a function
… Any clue?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
I get _this4.myfunc is not a function calling this ... - GitHub
I get _this4.myfunc is not a function calling this.myfunc() from onPress() of a TouchableHighlight in an item #130.
Read more >TouchableHighlight OnPress is not calling a function
I'm making an app in React Native and i have a problem that i don't understand.
Read more >TouchableHighlight - React Native
A wrapper for making views respond properly to touches. On press down, the opacity of the wrapped view is decreased, which allows the ......
Read more >Error: Undefined is not a function : r/reactnative - Reddit
For some reason, when I press my AddButton, I get the error "Undefined is not a function, evaluating "this.setModalVisible(true)".
Read more >What is the TouchableHighlight in react native - GeeksforGeeks
TouchableHighlight is a component that is used to provide a wrapper to Views in order to make them respond correctly to touch-based input....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@marcolino Did you make sure to bind
this
to your function in your constructor? Something along those lines:Thanks @NicholasBertazzon its working for me