Skip to content

React19 + Typescript fixes #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged

React19 + Typescript fixes #104

merged 2 commits into from
May 28, 2025

Conversation

ian-wd
Copy link

@ian-wd ian-wd commented May 28, 2025

  • Fixes react 19 ref cleanup TS error
  • Dropped global JSX usage and imports JSX type from react

React19 Cleanup function refs

Due to the introduction of ref cleanup functions, returning anything else from a ref callback will now be rejected by TypeScript. The fix is usually to stop using implicit returns, for example:

- <div ref={current => (instance = current)} />
+ <div ref={current => {instance = current}} />

The original code returned the instance of the HTMLDivElement and TypeScript wouldn’t know if this was supposed to be a cleanup function or if you didn’t want to return a cleanup function.

@ian-wd ian-wd requested a review from iBotPeaches May 28, 2025 01:18
@iBotPeaches iBotPeaches merged commit 25f50fa into master May 28, 2025
1 check passed
@iBotPeaches iBotPeaches deleted the typescript-fixes branch May 28, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants