sablono icon indicating copy to clipboard operation
sablono copied to clipboard

Add support for directly use other react component

Open dum3ng opened this issue 8 years ago • 3 comments

In reagent, we can just directly use react component by

[:> SomeComponent {} ...]

while sablono seems not support this. Now I need to write wrapper functions which made the syntax not looked so concise compared with just using vector.

How about it?

dum3ng avatar Mar 31 '18 05:03 dum3ng

Hi @dum3ng,

this has been asked a couple of times before. I'm not keen on extending the Sablono/Hiccup language with something like this at the moment, since it adds a lot more complexity. My main concern with something like this is server side rendering.

For now, I would suggest to wrap this in a function if you use this a lot.

We can revisit this later.

r0man avatar Mar 31 '18 10:03 r0man

Just discussed this over at the Rum issue tracker :)

https://github.com/tonsky/rum/issues/183

Would be really nice to be able to refer to a React component class in place of a symbol. Something like [js/MyReactComponent {} ...], just as simple as [:div {} ...].

Currently, you have to do something like this:

(js/React.createElement js/MyComponent
  #js { }
  (sablono.core/html [:div [:p "Hello, world"]]))

Which is a whole lot more cumbersome.

I can try to write up a PR if you would consider something like that!

augustl avatar Jan 08 '19 15:01 augustl

Hi @augustl ,

I didn't add this yet, because of server side rendering. How would that work? The only solution I had in mind so far is emitting a blank div or something like that.

Give it a try, but please keep the server side rendering in mind. Server side rendering is done via om.next at the moment, but since not much is happening with om.next I thought about borrowing that code and remove that dependency (which causes some problems already).

r0man

r0man avatar Jan 08 '19 18:01 r0man