this state returns undefined react native

Solutions on MaxInterview for this state returns undefined react native by the best coders in the world

showing results for - "this state returns undefined react native"
Pietro
12 Oct 2018
1The issue that in the first example toggle() is not bound to the correct this.
2
3You can either bind it in the constructor:
4
5constructor(props) {
6    super(props);
7    this.toggle = this.toggle.bind(this);
8    ...
9    
10Or use an instance function (OK under some circumstances):
11
12toggle = () => {
13    ...
14}