Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. (defn- -create-react-component
  2. "create a 'inline' component and set the display name to the same name as the function"
  3. [f]
  4. (let [component (fn [js-props]
  5. (let [args (.-uixprops js-props)]
  6. (hiccup->react (apply f args))))]
  7. (set! (.-displayName component) (.-name f))
  8. component))
  9.  
  10. ;; obvious optimization if obvious
  11. (defonce ^:private create-react-component (memoize -create-react-component))
  12.  
  13. ;; compile method for components
  14. (defmethod compile-hiccup-ast :component [[_ {:keys [type args] :as c}]]
  15. (react/createElement (create-react-component type)
  16. #js{:uixprops args}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement