From 9b3bfe56bb29276807389c21b13c77b6c40e9175 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 16 Sep 2018 09:01:05 +0200 Subject: [PATCH] Ensured list filtering params are reset when list component unmounts --- src/short-urls/ShortUrlsList.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/short-urls/ShortUrlsList.js b/src/short-urls/ShortUrlsList.js index 43335d7f..40c96ad3 100644 --- a/src/short-urls/ShortUrlsList.js +++ b/src/short-urls/ShortUrlsList.js @@ -11,7 +11,7 @@ import { serverType } from '../servers/prop-types'; import { ShortUrlsRow } from './helpers/ShortUrlsRow'; import { listShortUrls, shortUrlType } from './reducers/shortUrlsList'; import './ShortUrlsList.scss'; -import { shortUrlsListParamsType } from './reducers/shortUrlsListParams'; +import { shortUrlsListParamsType, resetShortUrlParams } from './reducers/shortUrlsListParams'; const SORTABLE_FIELDS = { dateCreated: 'Created at', @@ -23,6 +23,7 @@ const SORTABLE_FIELDS = { export class ShortUrlsListComponent extends React.Component { static propTypes = { listShortUrls: PropTypes.func, + resetShortUrlParams: PropTypes.func, shortUrlsListParams: shortUrlsListParamsType, match: PropTypes.object, location: PropTypes.object, @@ -89,6 +90,12 @@ export class ShortUrlsListComponent extends React.Component { this.refreshList({ page: params.page, tags: query.tag ? [ query.tag ] : shortUrlsListParams.tags }); } + componentWillUnmount() { + const { resetShortUrlParams } = this.props; + + resetShortUrlParams(); + } + renderShortUrls() { const { shortUrlsList, selectedServer, loading, error, shortUrlsListParams } = this.props; @@ -188,7 +195,7 @@ export class ShortUrlsListComponent extends React.Component { const ShortUrlsList = connect( pick([ 'selectedServer', 'shortUrlsListParams' ]), - { listShortUrls } + { listShortUrls, resetShortUrlParams } )(ShortUrlsListComponent); export default ShortUrlsList;