From 2576d35f0d5c91f463e2820aff1e0367f109002f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pet=C5=99=C3=ADk?= Date: Wed, 21 Jun 2023 10:43:24 +0200 Subject: [PATCH] fix(TextArea) fix validated example in docs --- .../src/components/TextArea/examples/TextAreaValidated.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-core/src/components/TextArea/examples/TextAreaValidated.tsx b/packages/react-core/src/components/TextArea/examples/TextAreaValidated.tsx index 87595305416..5714bbbf4a8 100644 --- a/packages/react-core/src/components/TextArea/examples/TextAreaValidated.tsx +++ b/packages/react-core/src/components/TextArea/examples/TextAreaValidated.tsx @@ -5,8 +5,12 @@ export const TextAreaValidated: React.FunctionComponent = () => { const [value, setValue] = React.useState(''); const [validated, setValidated] = React.useState<'default' | 'error' | 'warning' | 'success' | undefined>('default'); const [helperText, setHelperText] = React.useState('Share your thoughts.'); + const timerRef = React.useRef(null); const simulateNetworkCall = (callback: Function) => { - setTimeout(callback, 2000); + if (timerRef.current) { + clearTimeout(timerRef.current); + } + timerRef.current = setTimeout(callback, 2000); }; const handleTextAreaChange = (value: string) => {