-
Notifications
You must be signed in to change notification settings - Fork 22
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
[new feature] props rest syntax #169
base: master
Are you sure you want to change the base?
Conversation
master: PR: |
master: PR: |
master: PR: |
34c2362
to
d8d0a27
Compare
d8d0a27
to
2e429c8
Compare
master: PR: |
master: PR: |
master: PR: |
master: PR: |
Props transferring via rest and spread syntax
(spread syntax was already merged)
One thing that is sometimes useful in React/JavaScript, but doesn't exist in Clojure, is object spread and rest syntax for Clojure maps (see object spread in JS). It's often used for props transferring, to extract a subset of props and pass the rest to underlying components.
In Clojure, you'd have to
dissoc
keys manually, which is more verbose and can be frustrating for folks coming from JavaScript.For this specific reason, UIx adds syntactic sugar in
defui
and$
macros to support the pattern.Props rest syntax
When destructing props in
uix.core/defui
oruix.core/fn
all keys that are not mentioned in destructing form will be stored in a map assigned to:&
keyword. The syntax is composable with all other means of destructuring maps in Clojure, except that:&
exists only at top level, it won't work for nested maps.