Selector
什么是 selector?
reselect 计算缓存
import { createSelector } from 'reselect';
import { get } from 'lodash';
const getTaxSubtotal = proforma => get(proforma, 'ubl.TaxTotal[0].TaxSubtotal');
const getTaxAmount = proforma => get(proforma, 'ubl.TaxTotal[0].TaxAmount');
export const getTaxTotal = createSelector(
[getTaxSubtotal, getTaxAmount],
(taxSubtotal, taxAmount) => ({
taxAmount,
taxSubtotal:
taxSubtotal &&
taxSubtotal.map(item => ({
taxableAmount: get(item, 'TaxableAmount.value'),
taxScheme: get(item, 'TaxCategory.TaxScheme.Name.value'),
taxAmount: get(item, 'TaxAmount.value')
}))
})
);Last updated