Skip to content

Commit

Permalink
Nested the actual text caption of each list item in a sub-field 'capt…
Browse files Browse the repository at this point in the history
…ion'. This is to allow for keeping track of other data for each item via other sub-fields.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent 5bd1dc3 commit e1f5345
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions webpack_in/entry.jsx
Expand Up @@ -78,11 +78,13 @@ class ListWidget extends React.Component {
constructor(props) {
super(props);

this._mutateStateToAddItem = (state, strItemNew) => ({
this._mutateStateToAddItem = (state, strItemCaption) => ({
...state,
items: [
...state.items,
strItemNew
{
caption: strItemCaption
}
],
total_added: state.total_added + 1
});
Expand All @@ -106,8 +108,8 @@ class ListWidget extends React.Component {
<div style={ objStyleCommon }>
<div style={ objStyleContent }>
<ul style={{ display: 'inline-block', textAlign: 'left' }}>
{ this.state.items.map((strItem, index) => (<li key={ index }>
{ strItem }
{ this.state.items.map((objItem, index) => (<li key={ index }>
{ objItem.caption }
</li>)) }
</ul>
</div>
Expand Down

0 comments on commit e1f5345

Please sign in to comment.