-
Notifications
You must be signed in to change notification settings - Fork 127
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
Idea: A fn like macro for defining HOF stateless component? #92
Comments
Do you mean something beyond what defc can do right now? Can you give an On Tue, Jul 26, 2016, 21:34 Fong Hou [email protected] wrote:
|
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.
Cheers! |
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 |
Stateless components are supported since 0.10.0. If you use no mixins, component will be compiled to single stateless function |
Closing this due to no activity. Also we don't want to do any fancy stuff with components definition. |
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!
The text was updated successfully, but these errors were encountered: