-
Notifications
You must be signed in to change notification settings - Fork 348
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
[RFC] Custom element props #567
Conversation
One thought for how we could do this is to use (unfortunately for React stuff we may have to fork) tyxml to be able to generate this code. |
I'd love the ability for components to be just functions. Explicitly opening As for the generation, how are the elements + attributes defined for React itself? Perhaps we can use the same approach? |
I think they don't have a list defined anymore. They got rid of the attributes list in v16 (https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html) because they pretty much had the same problems ReasonReact is having with custom attributes. (#230) For the elements they only go by casing. Everything uppercased is a component, everything lowercased is treated as a valid DOM-Element and sent to the browser. Thats why you can even render "invalid" elements like So we would diverge from the way React is currently working and this is, besides the huge maintainability cost, the only thing concerning me with this RFC. |
If we can generate it from the DOM-spec somehow, it would be low-maintenance AND typesafe! :) |
This PR starts the process of moving
<div />
from getting compiled toReact.createElement("div", ...)
to forcing<ReactDOM.div />
which would compile toReact.createElement("div", ...)
. This has a bunch of side-effects but from an API perspective it makes Upper- and lower-cased PPX no longer distinguished. JSX<x>
just becomes sugar for grabbing a function pairx
andxProps
in scope.This is just a proof of concept and a general idea. I would love to have discussion about the following:
Is this a good/worthwhile idea?
This is a major change with big consequences.
Pros:
<lowercase />
JSX syntax to find functions in scopeCons:
<div />
goes to<ReactDOM.div />
open
, which isn't great to use widelyThe best way to generate and maintain this code
This file will be absolutely massive and incredibly prone to error if I manually create all of these. What ideas do you have for initial generation and maintenance of these?
Final API
Does
ReactDOM
make sense for this? Should it live somewhere else?