Giter VIP home page Giter VIP logo

Comments (8)

DjebbZ avatar DjebbZ commented on July 25, 2024 2

I was going to open this very issue :)

I'm interested into using hx to replace rum, in an isomorphic setup Browser/JVM. I'm talking about a real-world website that makes millions of views per day. The problem with rum is that it deviates too much from React.js, especially since the introduction of hooks.

If you want help with that:

  1. I can provide, time permitting, tests, code reviews and maybe patches!
  2. Look at what rum does in its test suite: it renders rum code to string, then compiles the same code with node.js and compares the output (basically just a =). I think it's a viable strategy.
  3. I haven't check all hooks, but useState in CLJ could just return the initial value and use it to render to initial HTML string. Will be happy to investigate with you the problem space.

My advice, if you permit: keep the layer that hx brings on top of React.js as thin as possible, don't create unnecessary abstractions, or even don't create abstractions at all, and hx would be a killer library that stays as close to React.js as possible, especially since the design of React.js is still a giant real-world WIP. Too dangerous to introduce abstractions that could deviate any time React introduce novelty.

Thanks for reading me!

from hx.

lilactown avatar lilactown commented on July 25, 2024 1

The problem I see is that you wouldn't be able to use any 3rd party Hooks or components which are included from JS-land. I'm also not at all interested in implementing streaming rendering in CLJ, which Node.js SSR will eventually support with React Suspense.

This means that you have to separate your code base between which components and hooks are OK to use on the server vs. client-side only. Perhaps this is OK, since you could use reader-conditionals to ensure this happens. It just might be surprising.

Overall it might be a lot of work and enforce certain restrictions on the user's code that I'm not sure is worthwhile. I am listening though and will continue to consider spending some time on it in the coming weeks.

from hx.

pepe avatar pepe commented on July 25, 2024

@DjebbZ well said. Even as I am pursuing the pure cljs way, This has value.

But the question is if it should be part of the core library?

from hx.

DjebbZ avatar DjebbZ commented on July 25, 2024

from hx.

DjebbZ avatar DjebbZ commented on July 25, 2024

from hx.

pepe avatar pepe commented on July 25, 2024

Sorry for the delay.

For me it is mostly project focus, and I am not at all opposed to this idea, nor I have any say in this. Actually sorry for the noise.

from hx.

DjebbZ avatar DjebbZ commented on July 25, 2024

Sure, it's all up to @Lokeh. Maybe he'll consider this feature useless for his use case, or too complex, or too whatever.

from hx.

lilactown avatar lilactown commented on July 25, 2024

What I've done to move the needle on this is completely decouple the hiccup parser from React. The API now is like this:

(def hiccup-config
  {:create-element create-element-impl
   :is-element? is-element-impl
   :is-element-type? is-elemene-type-impl
   :fragment fragment-impl})

(hx.hiccup/parse hiccup-config [:div "Hello, hiccup!"])

This will use the functions provided in the hiccup-config map to transform the tree.

In hx.react, these map to react/createElement, react/isValidElement, etc.

I have pushed a proof of concept HTML string renderer in a separate branch: https://github.com/Lokeh/hx/blob/html/src/hx/html.clj

This would allow someone (either this library, or even an external library) to leverage hx.hiccup for hiccup parsing and implement their own "engine" to generate HTML strings, cljfx maps, or whatever you want while sharing the same hiccup syntax as the hx library.

from hx.

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.