Components
UIx components are normal ClojureScript functions that return Hiccup (DSL for HTML and React's Virtual DOM).
Even though components are declared as functions, they are still used in Hiccup form[component arg1 arg2 ...]
Attributes
Hiccup attributes are written as keywords in kebab-case. Values that are normally strings without whitespace can be written as keywords as well, this may also improve autocompletion in your IDE.
:key attribute
Unique keys are used in React to optimize rendering lists of items. In UIx :key
attribute can be passed as normal attribute onto DOM elements such as :div
When rendering UIx components :key
should be declared via metadata, unless you are passing useful data to a component.
:ref attribute
Refs provide a way to refer to DOM nodes or React elements. In UIx ref is provided as Atom-like data type. Ref is passed as a normal attribute onto DOM elements.
UIx components doesn't take refs because they are built on top of React's function-based components that doesn't have instances.
When you need to pass a ref into child component, pass it as a normal value.
Last updated