Skip to content

Conversation

@dammafra
Copy link

Why

Resolves #2578

This PR fixes a bug where the onChange callback provided to the KeyboardControls component retains a stale closure if the function depends on reactive state or props from the parent component. This leads to the control handler executing with outdated values.

What

I have updated the internal useEffect hook within KeyboardControls that manages the event listener registration. The solution is to explicitly include the onChange prop in the dependency array of that useEffect.

Checklist

  • Ready to be merged

@vercel
Copy link

vercel bot commented Nov 25, 2025

@dammafra is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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.

KeyboardControls onChange callback retains stale closure when dependencies change

1 participant