Skip to content

Commit 4f1b9e3

Browse files
authored
Fix bug when switching collection or sketch lists (fixes #1401) (#1416)
* Update sketch/collection list when URL changes (fixes #1401) Using the username as the key prop causes the List component to remount when the username changes. This means we don't have to bother resetting everything when the user changes. * Update deprecated SketchList lifecycle methods From componentWillReceiveProps to componentDidUpdate
1 parent 138bfd6 commit 4f1b9e3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

client/modules/IDE/components/SketchList.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ class SketchList extends React.Component {
333333
};
334334
}
335335

336-
componentWillReceiveProps(nextProps) {
337-
if (this.props.sketches !== nextProps.sketches && Array.isArray(nextProps.sketches)) {
336+
componentDidUpdate(prevProps) {
337+
if (this.props.sketches !== prevProps.sketches && Array.isArray(this.props.sketches)) {
338+
// eslint-disable-next-line react/no-did-update-set-state
338339
this.setState({
339340
isInitialDataLoad: false,
340341
});

client/modules/User/pages/DashboardView.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ class DashboardView extends React.Component {
9898
renderContent(tabKey, username) {
9999
switch (tabKey) {
100100
case TabKey.assets:
101-
return <AssetList username={username} />;
101+
return <AssetList key={username} username={username} />;
102102
case TabKey.collections:
103-
return <CollectionList username={username} />;
103+
return <CollectionList key={username} username={username} />;
104104
case TabKey.sketches:
105105
default:
106-
return <SketchList username={username} />;
106+
return <SketchList key={username} username={username} />;
107107
}
108108
}
109109

0 commit comments

Comments
 (0)