Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactored <ListWidget> to render the items to display from its state…
… field 'items', which references an array of those items, and initialized that field to the same items as rendered previously.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent a33e375 commit d835e40
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions webpack_in/entry.jsx
Expand Up @@ -77,16 +77,24 @@ class TextWidget extends React.Component {
class ListWidget extends React.Component {
constructor(props) {
super(props);

this.state = {
items: [
"Item 1",
"Item 2",
"Item 3"
]
};
}

render() {
return (
<div style={ objStyleCommon }>
<div style={ objStyleContent }>
<ul style={{ display: 'inline-block' }}>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
{ this.state.items.map((strItem, index) => (<li>
{ strItem }
</li>)) }
</ul>
</div>
<div>
Expand Down

0 comments on commit d835e40

Please sign in to comment.