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

Sanity check on using hx for hiccup from helix #34

Closed
aiba opened this issue Mar 2, 2020 · 1 comment
Closed

Sanity check on using hx for hiccup from helix #34

aiba opened this issue Mar 2, 2020 · 1 comment

Comments

@aiba
Copy link
Contributor

aiba commented Mar 2, 2020

I couldn't get either sablono or hicada to work with React Native elements, and I always had good success with hx, so I've been using this defnc macro:

(defmacro defnc [type params & body]
  (let [default-opts {:helix/features {:fast-refresh true}}
        [opts body] (if (map? (first body))
                      [(first body) (rest body)]
                      [{} body])]
    `(helix.core/defnc ~type ~params
       ~(merge default-opts opts)
       (hx.react/f (do ~@body)))))

Just wanted a sanity check that hx.react/f is the right way to wrap hiccup bodies.

I could also create a PR adding a note to docs/react-native that this seems to be the best way to get hiccup working for helix + react-native.

@lilactown
Copy link
Owner

yeah, using hx/f is the best way!

I think it will be difficult to use sablono and hicada in a custom defnc macro since they try and parse at compile time, which means it needs to inspect all of the lets that are often used in helix component bodies. Using their html macros explicitly in each component is probably the best option for now.

Libraries that do fast runtime interpretation (hx, reagent) can easily be wrapped in a custom macro like you have here!

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

No branches or pull requests

2 participants