($ 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}))
Create a new React element from a valid React type.
Example:
($ MyComponent
"child1"
($ "span"
{:style {:color "green"}}
"child2" ))
Create a new React element from a valid React type. Example: ``` ($ MyComponent "child1" ($ "span" {:style {:color "green"}} "child2" )) ```
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" ))
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" )) ```
(<> & children)
Creates a new React Fragment Element
Creates a new React Fragment Element
(defcomponent display-name & spec)
Defines a React class component.
Defines a React class component.
(defnc display-name & form-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.
(factory type)
Creates a factory function for a React component
Creates a factory function for a React component
(-type factory)
Extracts the underlying type from the factory function.
Extracts the underlying type from the factory function.
(memo component)
(memo component compare)
Like React.memo, but passes props as CLJS map-likes instead of JS objects.
Like React.memo, but passes props as CLJS map-likes instead of JS objects.
(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)
(register! type id)
Registers a component with the React Fresh runtime.
type
is the component function, and id
is the unique ID assigned to it
(e.g. component name) for cache invalidation.
Registers a component with the React Fresh runtime. `type` is the component function, and `id` is the unique ID assigned to it (e.g. component name) for cache invalidation.
(suspense {:keys [fallback]} & children)
Creates a React Suspense boundary.
Creates a React Suspense boundary.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close