Fixed problem while 'reloading' a page with different route params not making the server to be hit

This commit is contained in:
Alejandro Celaya
2018-07-18 19:01:43 +02:00
parent 22406d1253
commit 5a7ac69aff
2 changed files with 6 additions and 12 deletions

View File

@@ -6,10 +6,14 @@ import './ShortUrls.scss';
import ShortUrlsList from './ShortUrlsList';
export function ShortUrls(props) {
const { match: { params } } = props;
// Using a key on a component makes react to create a new instance every time the key changes
const urlsListKey = `${params.serverId}_${params.page}`;
return (
<div className="short-urls-container">
<div className="form-group"><SearchBar /></div>
<ShortUrlsList {...props} shortUrlsList={props.shortUrlsList.data || []} />
<ShortUrlsList {...props} shortUrlsList={props.shortUrlsList.data || []} key={urlsListKey} />
<Paginator paginator={props.shortUrlsList.pagination} serverId={props.match.params.serverId} />
</div>
);