Closed cknitt closed 2 years ago
@mattdamon108 there was a bit of back and forth about where to put the source of truth for these things.
Since the source of truth for types is now the compiler's Jsx
e.g. type element = Jsx.element
, I guess it makes sense to also put these functions there, unless there are some issues with this, which were discussed but I have forgotten?
Sorry for missing the notification.
First of all, adding Jsx
is a first step to embracing other JSX libraries besides the React. Therefore, I added the primitives such as types there. Second, we removed the function such as addKeyProp
was the inline issue, as I remember. https://github.com/rescript-lang/rescript-compiler/pull/5677#discussion_r975274485
Ok, so my understanding is:
Jsx
stuff is meant to be framework-neutral and is part of the compiler repoaddKeyProp
needs to be colocated with createElementWithKey
and createElementVariadicWithKey
Correct?
So my suggestion would be to move addKeyProp
, createElementWithKey
and createElementVariadicWithKey
out of @rescript/react and into a new "PPX support module" in the compiler repo. Which means that we'd also need to duplicate the corresponding React.createElement
bindings there. But that should be fine.
This way the PPX + its support code can evolve independently from @rescript/react, and users of the React bindings are not tempted to invoke some PPX-internal functions.
Yes, correct.
I agreed. If we move the helper functions out of rescript-react, then non-zero cost js output would be cleaned from it. It would make the rescript-react a binding module.
Sounds great.
@cknitt Can we close it?
Yes, done 😄
Currently, the
React
module has the functionscreateElementWithKey
andcreateElementVariadicWithKey
.In my understanding, these are helper functions required for the JSX 4 PPX, but are not meant to be used by a user of the React bindings.
I would therefore propose to move them to a separate module, something like
ReactPPX4Support
. What do you think @mattdamon108?