Last active
February 27, 2016 15:33
-
-
Save DonDebonair/98ec2c2d14c200becd8a to your computer and use it in GitHub Desktop.
Generate keys for children in reagent component automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defcomponent [name attrs & body] | |
(let [i (.indexOf attrs '&)] | |
(if (> i -1) | |
(let [sym (get attrs (inc i))] | |
`(defn ~name ~attrs | |
~@(postwalk-replace {sym `(with-idx ~sym)} body))) | |
`(defn ~name ~attrs | |
~@body)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment