Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions components/SLDSLookup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SLDSLookup extends React.Component {
}

componentDidMount(){
this.modifyItems();
this.modifyItems(this.props.items);
}

componentDidUpdate(prevProps, prevState){
Expand Down Expand Up @@ -237,8 +237,8 @@ class SLDSLookup extends React.Component {
);
}

modifyItems () {
const items = this.props.items.map((item, index) => {
modifyItems (itemsToModify) {
const items = itemsToModify.map((item, index) => {
return {
id : 'item-' + index,
label: item.label,
Expand All @@ -250,7 +250,9 @@ class SLDSLookup extends React.Component {
}

componentWillReceiveProps (newProps) {
this.modifyItems();
if(newProps.items){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need the check, but better safe than sorry since the propTypes don't require the field. (That's actually something I feel should be changed everywhere in the repo. Add .isRequired to the end of propType declarations if it's a required prop.)

this.modifyItems(newProps.items);
}
}

render(){
Expand Down