Comments (5)
Do you mean something beyond what defc can do right now? Can you give an
example use case?
On Tue, Jul 26, 2016, 21:34 Fong Hou [email protected] wrote:
Hello,
Would it be useful for a fn like macro, as to defc stateless component?
I'm thinking it'd be useful for higher-order function/component use cases.
Essentially, what :wrap-render mixins do right now.Thanks!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#92, or mute the thread
https://github.com/notifications/unsubscribe-auth/AARabK2zxZICFWV66ZLBaBv4ynsSrv2aks5qZhr9gaJpZM4JVNlM
.
from rum.
Hi @tonsky,
I'm still exploring the idea, sorry can't show a good concrete example. Basically, renders that can be defined in (let [...]) form as lexical closures, rather than only top level vars by defc. This would create something I'd call dynamic configured stateless components, even allow them (I mean their definition, not args on invocation) observe parent owner's pre-render lifecycle events.
Right now, I copy this snippet to an utility function. It's fine for me just playing with the idea.
(defn render [render-fn]
(let [class (fn [props]
(apply render-fn (aget props ":rum/args")))
_ (aset class "displayName" (.-name render-fn))
ctor (fn [& args]
(js/React.createElement class #js { ":rum/args" args }))]
(with-meta ctor { :rum/class class })))
Cheers!
from rum.
React (as of 14, i think) calls the following pattern stateless components:
(defn stateless-component [props]
(html [:pre (pprint-str props)]))
;; ...
(js/React.createElement
stateless-component
#js{:title "Stateless" :other "Other"}
"Foo" "Bar")
=>
<pre>#js {:title "Stateless", :other "Other", :children #js ["Foo" "Bar"]}</pre>
Sablono doesn't allow direct use of react components (see r0man/sablono#46), but we could consider supporting stateless components as outlined in the previous comment. The react team has been talking about adding optimiziations for stateless components, though I'm not sure whether they would beat rum/static
.
from rum.
Stateless components are supported since 0.10.0. If you use no mixins, component will be compiled to single stateless function
from rum.
Closing this due to no activity. Also we don't want to do any fancy stuff with components definition.
from rum.
Related Issues (20)
- rum/fragment with React components HOT 2
- optimizations :advanced (shadow-cljs) failing on simple :form :input
- defc error with shadow-cljs. Makes Rum unusable for me... :( HOT 22
- daiquiri: fragment? fails on vectors HOT 13
- Question about rendering performance when updating state asynchronously HOT 9
- should-update error
- Big performance regression between 0.11.5 and 0.12.3 HOT 9
- Server/client difference when rendering nil HOT 2
- require-lazy macro unnecessarily prescriptive about namespace/module structure HOT 1
- Error when use `rum/local` and `rum/use-callback` together HOT 2
- Hydration not fully compatible with React 18 HOT 4
- bind-context produces unfixable infer warnings HOT 3
- `with-key` and `with-ref` Removing children? HOT 2
- ClojureScript >=1.11.51 seems to break Rum HOT 4
- ClojureScript >=1.11.51 seems to break Rum HOT 3
- How to use daiquiri.core/html ? HOT 9
- How can I use npm based react library I rum ssr mode HOT 4
- Live Examples Missing HOT 1
- Hulunote(a tool for networked thought) use the rum😄
- Interpretation warnings print var symbol instead of the value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rum.