($ type & args)Create a new React element from a valid React type.
Will try to statically convert props to a JS object.
To pass in dynamic props, use the special & or :& key in the props map
to have the map merged in.
Simple example:
($ my-component "child1" ($ "span" {:style {:color "green"}} "child2" ))
Dynamic exmaple:
(let [dynamic-props {:foo "bar"}] ($ my-component {:static "prop" & dynamic-props}))
Create a new React element from a valid React type.
Will try to statically convert props to a JS object.
To pass in dynamic props, use the special `&` or `:&` key in the props map
to have the map merged in.
Simple example:
($ my-component
"child1"
($ "span"
{:style {:color "green"}}
"child2" ))
Dynamic exmaple:
(let [dynamic-props {:foo "bar"}]
($ my-component
{:static "prop"
& dynamic-props}))
(defnc type params & body)Creates a new functional React component. Used like:
(defnc component-name "Optional docstring" [props ?ref] {,,,opts-map} ,,,body)
"component-name" will now be a React function component that returns a React Element.
Your component should adhere to the following:
First parameter is 'props', a map of properties passed to the component.
Second parameter is optional and is used with React.forwardRef.
'opts-map' is optional and can be used to pass some configuration options to the macro. Current options:
'body' should return a React Element.
Creates a new functional React component. Used like:
(defnc component-name
"Optional docstring"
[props ?ref]
{,,,opts-map}
,,,body)
"component-name" will now be a React function component that returns a React
Element.
Your component should adhere to the following:
First parameter is 'props', a map of properties passed to the component.
Second parameter is optional and is used with `React.forwardRef`.
'opts-map' is optional and can be used to pass some configuration options to the
macro. Current options:
- ':wrap' - ordered sequence of higher-order components to wrap the component in
- ':helix/features' - a map of feature flags to enable. See "Experimental" docs.
'body' should return a React Element.(provider {:keys [context value] :as props} & children)Creates a Provider for a React Context value.
Example:
(def my-context (react/createContext))
(provider {:context my-context :value my-value} child1 child2 ...childN)
Creates a Provider for a React Context value.
Example:
(def my-context (react/createContext))
(provider {:context my-context :value my-value} child1 child2 ...childN)(suspense {:keys [fallback] :as props} & children)Creates a new React Fragment Element
Creates a new React Fragment Element
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |