question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"_this2.setState is not a function."

See original GitHub issue

I’m a new for rect-native, but I even can’t run the example which is given. It get the error as title when it run the code: this.setState({ avatarSource: source }); and when I add the invoker into my own project, it give another warning and doesn’t work properly: Attempt to present <UIAlertController: 0x7ff8ad99e9d0> on <UIImagePickerController: 0x7ff8c49f2e00> whose view is not in the window hierarchy! Is there some wrong with my environment?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

36reactions
Julia-Lavrovacommented, Dec 1, 2017

try use () => {}

  showActionSheet = () => {
    {your code}
  } 
22reactions
yfukscommented, Feb 16, 2016
_this2.setState is not a function

mean that you don’t have the react class context in your function

for exemple on the onPress you can do like :

onPress={() => this.myFunction()}

To bind your react class context into your function

Read more comments on GitHub >

github_iconTop Results From Across the Web

React - _this2.SetState is not a function - Stack Overflow
Try this: class SearchBar extends Component { constructor(props) { super(props); this.state = { term: '' }; this.setInputState = this.
Read more >
React Error: "this.setstate is not a function" - How to Fix
"this.setstate is not a function" is a common error message that comes up in React. In this article, we'll learn how to fix...
Read more >
[Solved]-React TypeError: "_this2.setState is not a function"?
Coding example for the question React TypeError: "_this2.setState is not a function"?-Reactjs.
Read more >
this.setstate is not a function - Code Examples & Solutions For ...
Make sure you use arrow functions to correctly bind 'this' handlePageChange = (page) => { this.setState({ currentPage: page }); } This will give...
Read more >
React - setState is not a function - debuggr.io
setState is not a function. TL;DR - If you are not in the mode for reading or you just want the bottom line,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found