Skip to content

Commit b76d71b

Browse files
committed
Added logic to propagate the value of each 'is_checked' field corresponding to each item in the <ListWidget> React 'state' to each <ListItem> via 'props', and to also update the checkbox within each <ListItem> accordingly.
1 parent 752ef57 commit b76d71b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

webpack_in/entry.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ class TextWidget extends React.Component {
7676

7777
class ListItem extends React.Component {
7878
render() {
79-
return (<li><input type='checkbox' />{ this.props.caption }</li>);
79+
return (<li><input type='checkbox'
80+
checked={ this.props.isChecked }/>{ this.props.caption }</li>);
8081
}
8182
}
8283

8384
ListItem.propTypes = {
84-
caption: PropTypes.string.isRequired
85+
caption: PropTypes.string.isRequired,
86+
isChecked: PropTypes.bool.isRequired
8587
};
8688

8789
class ListWidget extends React.Component {
@@ -123,6 +125,7 @@ class ListWidget extends React.Component {
123125
{ this.state.items.map((objItem, index) => (
124126
<ListItem key={ objItem.id }
125127
caption={ objItem.caption }
128+
isChecked={ objItem.is_checked }
126129
/>
127130
)) }
128131
</ul>

0 commit comments

Comments
 (0)