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) => {