Git Product home page Git Product logo

Comments (7)

Deraen avatar Deraen commented on June 7, 2024 1

This is probably already possible with the Compiler protocol. make-element method is quite close to the createElement:
https://github.com/reagent-project/reagent/blob/master/src/reagent/impl/template.cljs#LL320C11-L320C11
https://github.com/reagent-project/reagent/blob/master/src/reagent/impl/template.cljs#L128-L141
https://github.com/reagent-project/reagent/blob/master/doc/ReagentCompiler.md

You might have to refer to some impl functions to reuse the code for other methods, so the API isn't perfect, but if you get it working I can consider exposing the necessary functions.

from reagent.

Deraen avatar Deraen commented on June 7, 2024

Checking your fork, there are few other createElement calls besides make-element but I'm quite sure that those don't matter, because the elements created in those cases refer to functions, not HTML elements, and they wouldn't use css.

from reagent.

cj-price avatar cj-price commented on June 7, 2024

Awesome, thanks for the feedback. I'll take a look at implementing it with the compiler

from reagent.

cj-price avatar cj-price commented on June 7, 2024

Have it working with the compiler here: cj-price@e09a8e6

I haven't tested the other places where react/createElement is used but for general use the compiler protocol seems more than enough to implement something like this.

Would you like me to clean up the example and submit a PR?

from reagent.

Deraen avatar Deraen commented on June 7, 2024

I guess Emotion is interesting enough to add a example to the repository.

The root package.json probably doesn't need to be changed?

The example should use shadow-cljs so it can use npm packages. There is an example in the material-ui folder.

The simple-example component seems unnecessary, as you can set the compiler directly on the render call. But perhaps it is for use from the intro ns now?

from reagent.

Deraen avatar Deraen commented on June 7, 2024

And a link could be added the compiler protocol docs to the example folder.

from reagent.

cj-price avatar cj-price commented on June 7, 2024

I submitted #593

I am using shadow-cljs as requested and removed the code from the intro. Also added a link on the docs. Willing to make any requested changes :)

The simple-example component seems unnecessary, as you can set the compiler directly on the render call. But perhaps it is for use from the intro ns now?

Yeah I did my testing on the intro which is why I rendered inside the simple example component.

from reagent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.