lantiga / react.hiccup

React 0% JSX, 100% hiccup
MIT License
81 stars 0 forks source link

parameterize props #7

Open hth2 opened 10 years ago

hth2 commented 10 years ago

I have this code:

hiccup
  [div
    [ComponentA {prop1: "abc", prop2: def"} 123]
    [ComponentB {prop1: "abc", prop2: def"} 456]
  ]

is it possible to have {prop1: "abc", prop2: def"} as a variable?

lantiga commented 10 years ago

I had thought about this when I first wrote the library, then I concluded not to support this - the same way it is not supported in JSX. The reason is that knowing if there are properties or not would only be known at runtime. In the end macroexpanded code would be significantly more convoluted and there would be additional runtime costs (which may or may not have an impact, we'd have to measure).

Having said this, I haven't made up my mind. I'm going to keep the issue open and think about it.

Currently the way around it is to define a component that directly embeds the properties.