Skip to content

Commit

Permalink
remove dependency on ueaq and react-dom/server, create $ as defn
Browse files Browse the repository at this point in the history
  • Loading branch information
lilactown committed Jan 31, 2020
1 parent 8dec451 commit e43b5ed
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/helix/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
[helix.impl.props :as impl.props]
["./impl/class.js" :as helix.class]
[cljs-bean.core :as bean]
[ueaq.core :as ueaq]
["react" :as react]
["react-dom/server" :as rds])
["react" :as react])
(:require-macros [helix.core]))


Expand All @@ -26,17 +24,14 @@
(def create-element react/createElement)


(defn $$
"Dynamically create a new React element from a valid React type.
`$` can typically be faster, because it will statically process the arguments
at macro-time if possible.
(defn $
"Create a new React element from a valid React type.
Example:
```
($$ MyComponent
($ MyComponent
\"child1\"
($$ \"span\"
($ \"span\"
{:style {:color \"green\"}}
\"child2\" ))
```"
Expand All @@ -57,6 +52,23 @@
args))))


(def $$
"Dynamically create a new React element from a valid React type.
`$` can typically be faster, because it will statically process the arguments
at macro-time if possible.
Example:
```
($$ MyComponent
\"child1\"
($$ \"span\"
{:style {:color \"green\"}}
\"child2\" ))
```"
$)


(defprotocol IExtractType
(-type [factory] "Extracts the underlying type from the factory function."))

Expand All @@ -70,9 +82,7 @@
"Creates a factory function for a React component"
[type]
(-> (fn factory [& args]
(if (map? (first args))
(apply create-element type (ueaq/ueaq (first args)) (rest args))
(apply create-element type nil args)))
(apply $ type args))
(specify! IExtractType
(-type [_] type))))

Expand Down

0 comments on commit e43b5ed

Please sign in to comment.