looking for some solutions? You are welcome.

SOLVED: What is the best way to declare a variable in react-native class (Best Way)

Muhammad:

As you can see there I used three way of declaring a var. Here I know when to use them, it returns to the scope we need to use them. And here all three ways work for me, But I need to khow which of them is best way, to save memory and work fast. and here someFunc may be called more than 10 time when it is mounted.

let outervar = 5;
class A extends Component{
  classvar = 5;

  someFunc(){
    let localvar = 10;
    this.classvar = 10;
    outervar = 10;
  }
}

my expectation is:

  1. it must work fast
  2. it must use low memory usage.
  3. it must not make one seprate instance or refernce in memory per function call.
  4. in every call the variable should free the last memory used for last value.


Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent