Answer the question
In order to leave comments, you need to log in
React Native. Variables in render and memory?
Two options:
1)
class MyClass extends Component {
constructor(props) {
//...
}
render {
let {a} = this.props.a
return <Text>{a}</Text>
}
}
class MyClass extends Component {
constructor(props) {
//...
}
render {
return <Text>{this.props.a}</Text>
}
}
Answer the question
In order to leave comments, you need to log in
There is such a statement - "premature optimization is the root of all evil." There is no need to do this if you do not see the difference in performance on your own example, therefore, in terms of performance, it does not matter which solution you use.
From the point of view of code readability, it is better to do destructuring, as it turns out more visually.
PS Correctly do let { a } = this.props
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question