-
Notifications
You must be signed in to change notification settings - Fork 84
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
React 19 #607
Comments
We should indeed add support for React 19, however I still can't find information on what the expected JavaScript is. All the documentation, I find are using JSX syntax but for Feliz we need to output result of the JSX compilation. Currently this is what we are doing: If in JSX you write const MyButton = () => <button /> the JavaScript version of that was: const MyButton = () => /*#__PURE__*/React.createElement("button", null); The equivalent in Feliz is [<ReactComponent>]
let MyButtion () =
Html.button [] which compiles to import { createElement } from "react";
import React from "react";
export function MyButtion() {
return createElement("button", {});
} Because of that I don't know yet if adding support for React 19, will be a breaking change or not. It is also important to note that the code currently generated by Feliz is not even yet up to the latest version of what React does. Since React 18 (I think), the recommended generated JavaScript is: import * as JsxRuntime from "react/jsx-runtime";
var MyButton = JsxRuntime.jsx("button", null); This is for example, the reason why when using Fast Refresh with Vite people need to set |
Looking at the changes in React 19, nothing strikes me as breaking from Feliz point of view. That said, current Feliz version defines its react dependency (via a transitive reference to |
I think the easiest way to see if something is broken or not would be for someone to upgrade to React 19 and we will see if React complains or something breaks :) |
So I ran into an issue with this recently, actually. My blog site - https://github.com/tw0po1nt/twopoint-website - uses Astro, and I recently tried integrating Fable and Feliz to write some custom React components in F#. In setting up, I used the latest React that npm installed - v19 in my case - and for a simple component, I got multiple of the following error: This is the component: module Test
open Feliz
type Components =
[<ReactComponent(exportDefault=true)>]
static member Test(config: string, ?key: string) =
Html.section [
prop.className "relative not-prose scroll-mt-[72px]"
prop.children [
Html.div [
prop.className "intersect-once motion-safe:md:intersect:animate-fade motion-safe:md:opacity-0 intersect-quarter mx-auto intercept-no-queue px-4 relative lg:py-20 md:px-6 md:py-16 py-12 text-default max-w-7xl"
prop.children [
Html.div [
prop.className "mb-8 md:mb-12 md:mx-auto text-center max-w-3xl"
prop.children [
Html.h2 [
prop.className "font-bold font-heading leading-tighter tracking-tighter text-heading text-3xl md:text-4xl"
prop.text "[Title]"
]
Html.p [
prop.className "text-muted text-xl mt-4"
prop.text "Lorem ipsum odor amet, consectetuer adipiscing elit. Mus tellus proin gravida litora consectetur iaculis conubia scelerisque. Hendrerit aenean massa tincidunt torquent tellus laoreet fusce habitasse."
]
]
]
]
]
]
] Bumping down to v18, this issue went away. I'd gladly try to make a contribution to help support React 19 by fixing this issue (and potentially others, if they arise). Where should I start? 🙂 |
The first thing would be to have a look at the generated code by standard tool when transforming JSX to check if there has been a meaningful change between React 18 and 19. Second, would be to make a reproduction example as small as possible so you can more easily inspect the generated code.
Check if the generated code does use one of these API: Lines 19 to 22 in 6841c9b
If that's the case, look at React the result of applying these functions between React 18 / 19 to see if they changed something. If I remember correctly, in the past using |
@lukaszkrzywizna I’m just wondering, why jsxRuntime instead of the much more battle-tested Preact? Preact is also a 3Kb drop-in replacement for React and works perfectly for me with Feliz (and Vite). |
@laurentpayot |
Hi, React 19 RC has been released a few weeks ago, with some breaking changes.
How will the soon to be released React 19 impact Feliz? Is React 19 compatibility planned?
The text was updated successfully, but these errors were encountered: