I have a quick question which I seem to be tripped up on.
I have a data structure like so:
data: {
accounts: [{
info: false
}]
}
Is there a "fancy" React way for me to get the value of the boolean associated with the info
key?
I can of course retrieve the value with using map
or find
, but it always ends up being somewhat convoluted or involved code.
If I do something like
const { accounts } = data;
const customer = accounts.map(a => a.info);
The value for customer
always ends up coming back as [false]
instead of just false
, which is really confusing me, because I am not sure why it would come back inside of an array, where it is not an array to begin with, and it is being mapped out of an array ( accounts
).
I had the same result when using forEach
and find
.
Is there something I'm missing? There has to be a quick Reactive one-liner to get the boolean value I'm looking for, and set it to a variable.
Anyone...?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.