[英]Negate A Destructured Value Assigned To A New Variable
我在React组件中有以下代码。
const { isDisclosed: showDisclosureButton } = this.state
问题是我需要showDisclosureButton
的值来showDisclosureButton
this.state.isDisclosed
。 相当于:
const showDisclosureButton = !this.state.isDisclosed
有没有办法否定分配给新变量的析构值?
不,那里没有。 写吧
const showDisclosureButton = !this.state.isDisclosed
它比任何解构都简单,清晰,更短。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.