Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn- -create-react-component
- "create a 'inline' component and set the display name to the same name as the function"
- [f]
- (let [component (fn [js-props]
- (let [args (.-uixprops js-props)]
- (hiccup->react (apply f args))))]
- (set! (.-displayName component) (.-name f))
- component))
- ;; obvious optimization if obvious
- (defonce ^:private create-react-component (memoize -create-react-component))
- ;; compile method for components
- (defmethod compile-hiccup-ast :component [[_ {:keys [type args] :as c}]]
- (react/createElement (create-react-component type)
- #js{:uixprops args}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement