Skip to content

Use inline elements directly instead of createElement #152

Open
@natefaubion

Description

@natefaubion
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.

Activity

natefaubion

natefaubion commented on Jun 5, 2018

@natefaubion
ContributorAuthor

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

ethul

ethul commented on Jun 5, 2018

@ethul
Contributor

Sounds good to me!

natefaubion

natefaubion commented on Jun 9, 2018

@natefaubion
ContributorAuthor

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

natefaubion commented on Jun 9, 2018

@natefaubion
ContributorAuthor

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

ethul commented on Jun 9, 2018

@ethul
Contributor

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

natefaubion

natefaubion commented on Jun 9, 2018

@natefaubion
ContributorAuthor

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

natefaubion commented on Jun 9, 2018

@natefaubion
ContributorAuthor

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

ethul commented on Jun 9, 2018

@ethul
Contributor

Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @natefaubion@ethul

        Issue actions

          Use inline elements directly instead of createElement · Issue #152 · purescript-contrib/purescript-react