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

Use inline elements directly instead of createElement #152

Open
natefaubion opened this issue Jun 5, 2018 · 8 comments
Open

Use inline elements directly instead of createElement #152

natefaubion opened this issue Jun 5, 2018 · 8 comments

Comments

@natefaubion
Copy link
Contributor

https://babeljs.io/docs/plugins/transform-react-inline-elements/

This would let us get around issues with createElement's API (which mixes in key and ref with the normal props), and avoid the headaches with the attempt in master at typing createElement.

@natefaubion
Copy link
Contributor Author

This would also let us remove the dynamic variants of elements.

@ethul
Copy link
Contributor

ethul commented Jun 5, 2018

Sounds good to me!

@natefaubion
Copy link
Contributor Author

I tried this out and it seemed to work alright, but if I mixed this with normal createElement I got a single warning about key props in array/iterators, which was strange. React seems to duplicate this check. Once in the createElement API, but then again as part of the reconciler, which I don't understand.

@natefaubion
Copy link
Contributor Author

Unfortunately, I don't think this is tractable. React does all sorts of crazy stuff in dev mode to secretly track validation, which means you'll get all sorts of strange warnings since the correct secret flags aren't in the correct secret place.

@ethul
Copy link
Contributor

ethul commented Jun 9, 2018

Thanks for giving this a go. Based on your findings, it sounds like it is probably best to leave this out for now.

@natefaubion
Copy link
Contributor Author

I think you could maybe createElement at startup and poke it to see if it has dev-mode validation flags, and conditionally add them. But I think I'd rather experiment with that at scale to see what kind of drawbacks it has. It's fine for production mode, but I'm not sure if it would make development confusing.

@natefaubion
Copy link
Contributor Author

Here is my branch with the appropriate switch if anyone wants to mess with it. https://github.com/natefaubion/purescript-react/tree/inline-elements

@ethul
Copy link
Contributor

ethul commented Jun 9, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants