From 0f92a9c6b73c7459bd4a979784b13cd69b8806fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CSelen?= <“selen.kockar@tedu.edu.tr”> Date: Fri, 3 Nov 2023 22:10:04 +0300 Subject: [PATCH 1/2] Fix OverlayPanel Toast --- components/doc/overlaypanel/datatabledoc.js | 54 +++++++++------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/components/doc/overlaypanel/datatabledoc.js b/components/doc/overlaypanel/datatabledoc.js index fafe59195c..21f98d8e13 100644 --- a/components/doc/overlaypanel/datatabledoc.js +++ b/components/doc/overlaypanel/datatabledoc.js @@ -29,12 +29,10 @@ export function DataTableDoc(props) { const toast = useRef(null); const isMounted = useRef(false); - useEffect(() => { - if (isMounted.current && selectedProduct) { - op.current.hide(); - toast.current.show({ severity: 'info', summary: 'Product Selected', detail: selectedProduct.name, life: 3000 }); - } - }, [selectedProduct]); // eslint-disable-line react-hooks/exhaustive-deps + const productSelect = (e) =>{ + op.current.hide(); + toast.current.show({ severity: 'info', summary: 'Product Selected', detail:e.data.name, life: 3000 }); + } useEffect(() => { isMounted.current = true; @@ -99,12 +97,10 @@ export default function DataTableDemo() { const toast = useRef(null); const isMounted = useRef(false); - useEffect(() => { - if (isMounted.current && selectedProduct) { - op.current.hide(); - toast.current.show({ severity: 'info', summary: 'Product Selected', detail: selectedProduct.name, life: 3000 }); - } - }, [selectedProduct]); + const productSelect = (e) =>{ + op.current.hide(); + toast.current.show({ severity: 'info', summary: 'Product Selected', detail:e.data.name, life: 3000 }); + } useEffect(() => { isMounted.current = true; @@ -133,11 +129,11 @@ export default function DataTableDemo() {