Skip to content

fix(react): pass numeric delay instead of array to setTimeout in typi… - #1413

Open
swarnendusahu10-dotcom wants to merge 1 commit into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/issue-1204-settimeout-delay-argument
Open

swarnendusahu10-dotcom wants to merge 1 commit into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/issue-1204-settimeout-delay-argument

Conversation

@swarnendusahu10-dotcom

Copy link
Copy Markdown
Contributor

Description

Closes #1204

Fixes an invalid delay argument in packages/react/src/views/ChatInput/ChatInput.js.

Previously, setTimeout was invoked with an array literal [15000] as its delay parameter instead of a number:

timerRef.current = setTimeout(() => {
  typingRef.current = false;
}, [15000]);

While JavaScript coerces a single-element array [15000] to "15000" and then to 15000, relying on implicit type coercion violates the setTimeout(handler, timeout) API contract and is fragile (e.g., multi-element arrays coerce to NaN, defaulting delay to 0).

Changes

  • Replaced the array literal [15000] with the numeric literal 15000.
  • Formatted with Prettier.

Test Coverage

  • Verified typing status timer schedules and cancels properly without relying on runtime type coercion.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Incorrect setTimeout Delay Argument Using Array Instead of Number

1 participant