Skip to content
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

[chore] Bump to React 19 #307

Merged
merged 4 commits into from
Dec 24, 2024
Merged

[chore] Bump to React 19 #307

merged 4 commits into from
Dec 24, 2024

Conversation

TodePond
Copy link
Contributor

Closes #306

Normally I wouldn't bother updating but React 19 removes the need for forwardRef which flok uses a lot because of juggling different UIs and editors. So it might make it easier to do more fixes, improvements, etc.

https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop

I came across this while working on #305

This PR

  • Bumps react
  • Bumps all radix packages
  • Replaces all forwardRefs to using ref as a prop

No worries if this isn't wanted! But I hope you see the appeal and I think it could help future work :) Lemme know!

@felixroos
Copy link
Contributor

i haven't used react 19 alot yet but they say it's stable so why not!

Copy link

@reckter reckter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@munshkr
Copy link
Owner

munshkr commented Dec 24, 2024

I had a couple of type errors when building because ref is marked as required prop on Button and Input, so I made them optional.

diff --git a/packages/web/src/components/ui/button.tsx b/packages/web/src/components/ui/button.tsx
index 67c464a..bb72199 100644
--- a/packages/web/src/components/ui/button.tsx
+++ b/packages/web/src/components/ui/button.tsx
@@ -35,7 +35,7 @@ const buttonVariants = cva(
 export interface ButtonProps
   extends React.ButtonHTMLAttributes<HTMLButtonElement>,
     VariantProps<typeof buttonVariants> {
-  ref: React.Ref<HTMLButtonElement>;
+  ref?: React.Ref<HTMLButtonElement>;
 }

 const Button = ({ className, variant, size, ref, ...props }: ButtonProps) => {
diff --git a/packages/web/src/components/ui/input.tsx b/packages/web/src/components/ui/input.tsx
index 8e0da2d..cd4bbf8 100644
--- a/packages/web/src/components/ui/input.tsx
+++ b/packages/web/src/components/ui/input.tsx
@@ -4,7 +4,7 @@ import { cn } from "@/lib/utils";

 export interface InputProps
   extends React.InputHTMLAttributes<HTMLInputElement> {
-  ref: React.Ref<HTMLInputElement>;
+  ref?: React.Ref<HTMLInputElement>;
 }

 const Input = ({ className, ref, ...props }: InputProps) => {

@TodePond do you think this will be fine?

@munshkr munshkr merged commit 26bd408 into munshkr:main Dec 24, 2024
2 checks passed
@munshkr
Copy link
Owner

munshkr commented Dec 24, 2024

Just went ahead and merge it. Thanks again!

@TodePond
Copy link
Contributor Author

amazing! and im not sure, i can take a look after christmas if no one else beats me to it :) seems to work(!?)

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.

[chore] Bump to React 19
4 participants