@@ -4,7 +4,7 @@ import React, { useEffect } from 'react';
44import { connect , ConnectedProps } from 'react-redux' ;
55import { Link , useHistory } from 'react-router-dom' ;
66import { PATH } from 'src/constants/paths' ;
7- import { getProducts } from './Product.thunks' ;
7+ import { getProducts , clearProduct } from './Product.thunks' ;
88
99const mapStateToProps = ( state : AppState ) => ( {
1010 loading : state . products . loading ,
@@ -13,6 +13,7 @@ const mapStateToProps = (state: AppState) => ({
1313
1414const mapDispatchToProps = {
1515 getProducts,
16+ clearProduct,
1617} ;
1718
1819const connector = connect ( mapStateToProps , mapDispatchToProps ) ;
@@ -21,7 +22,7 @@ interface Props extends ConnectedProps<typeof connector> {}
2122export const _ProductList = ( props : Props ) => {
2223 const history = useHistory ( ) ;
2324
24- const { products, getProducts } = props ;
25+ const { products, getProducts, clearProduct } = props ;
2526
2627 const columns = [
2728 {
@@ -64,6 +65,7 @@ export const _ProductList = (props: Props) => {
6465 } ;
6566
6667 const addNewProduct = ( ) => {
68+ clearProduct ( ) ;
6769 history . push ( PATH . PRODUCT_NEW ) ;
6870 } ;
6971
0 commit comments