coffee-react-transform icon indicating copy to clipboard operation
coffee-react-transform copied to clipboard

Supporting other virtual doms.

Open DylanPiercey opened this issue 9 years ago • 3 comments

Currently it's pretty easy to use something like https://github.com/dekujs/deku using coffee-react since you can do:

# @cjsx deku
Car = React.createClass
  render: ->
    <Vehicle {[email protected]}>
      <Parts.FrontSeat />
      <Parts.BackSeat />
      <p>Which seat can I take? {@props.seat or 'none'}</p>
    </Vehicle>

Which becomes:

`/** @jsx deku */`
Car = React.createClass
  render: ->
    deku.createElement(Vehicle, React.__spread({},  @props.parts),
      deku.createElement(Parts.FrontSeat, null),
      deku.createElement(Parts.BackSeat, null),
      deku.createElement("p", null, "Which seat can I take? ", (@props.seat or 'none'))
    )

However you will notice "React.__spread" which is obviously not compatible. Is it possible to have @jsx also modify React.__spread?

DylanPiercey avatar Jul 01 '15 05:07 DylanPiercey

Looks like this is a regression, previously if you provided something like # @cjsx deku.dom it would just work.

jsdf avatar Jul 01 '15 21:07 jsdf

Is it possible to fix or is it an issue with the jsx transform?

DylanPiercey avatar Jul 01 '15 21:07 DylanPiercey

It's a pretty simple fix, the correct value just needs to be output here: https://github.com/jsdf/coffee-react-transform/blob/master/src/serialiser.coffee#L105

jsdf avatar Jul 01 '15 21:07 jsdf