Skip to content

Commit d8a44ee

Browse files
committed
Merge pull request #41 from salesforce-ux/gpinto_lookup_update_items_with_new_props
Fixed the lookup not updating when props.items changes
2 parents ff7d9bf + c50802c commit d8a44ee

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/SLDSLookup/index.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SLDSLookup extends React.Component {
4040
}
4141

4242
componentDidMount(){
43-
this.modifyItems();
43+
this.modifyItems(this.props.items);
4444
}
4545

4646
componentDidUpdate(prevProps, prevState){
@@ -237,8 +237,8 @@ class SLDSLookup extends React.Component {
237237
);
238238
}
239239

240-
modifyItems () {
241-
const items = this.props.items.map((item, index) => {
240+
modifyItems (itemsToModify) {
241+
const items = itemsToModify.map((item, index) => {
242242
return {
243243
id : 'item-' + index,
244244
label: item.label,
@@ -250,7 +250,9 @@ class SLDSLookup extends React.Component {
250250
}
251251

252252
componentWillReceiveProps (newProps) {
253-
this.modifyItems();
253+
if(newProps.items){
254+
this.modifyItems(newProps.items);
255+
}
254256
}
255257

256258
render(){

0 commit comments

Comments
 (0)