0

I have the following render method that calls another method in its class:

render() {
   const isValidField = this.isValidField();
}

Is it possible - and if so is it a good idea - to use destructuring in this case to avoid repeating the method name in the variable?

I'm looking for something like this:

render() {
   const { isValidField }() = this;
}
alanbuchanan
  • 3,993
  • 7
  • 41
  • 64

1 Answers1

0

You could use a getter function:

get isValidField() {
    return true;
}

render() {
    const {isValidField} = this;
}
Aaron Beall
  • 49,769
  • 26
  • 85
  • 103