JSFiddle - React, Tailwind, and code Playground
by Adam Boduch
HTML
<script src="https://cdn.jsdelivr.net/immutable.js/3.6.4/immutable.min.js"></script>
JavaScript
const list = Immutable.fromJS([
{ a: true, b: 'two', job: { type: 'typeone' } },
{ a: false, b: 'two', job: { type: 'typetwo' } },
]);
const typeLabels = Immutable.fromJS({
typeone: 'Type One',
typetwo: 'Type Two'
});
const result = list
.map(i =>
i.setIn(
['job', 'label'],
typeLabels.get(
i.getIn(['job', 'type']),
i.getIn(['job', 'type'])
)
)
);
console.log(result.toJS());