* 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
This commit is contained in:
parent
138bfd6065
commit
4f1b9e3700
2 changed files with 6 additions and 5 deletions
|
@ -333,8 +333,9 @@ class SketchList extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.sketches !== nextProps.sketches && Array.isArray(nextProps.sketches)) {
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.sketches !== prevProps.sketches && Array.isArray(this.props.sketches)) {
|
||||
// eslint-disable-next-line react/no-did-update-set-state
|
||||
this.setState({
|
||||
isInitialDataLoad: false,
|
||||
});
|
||||
|
|
|
@ -98,12 +98,12 @@ class DashboardView extends React.Component {
|
|||
renderContent(tabKey, username) {
|
||||
switch (tabKey) {
|
||||
case TabKey.assets:
|
||||
return <AssetList username={username} />;
|
||||
return <AssetList key={username} username={username} />;
|
||||
case TabKey.collections:
|
||||
return <CollectionList username={username} />;
|
||||
return <CollectionList key={username} username={username} />;
|
||||
case TabKey.sketches:
|
||||
default:
|
||||
return <SketchList username={username} />;
|
||||
return <SketchList key={username} username={username} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue