Fork me on GitHub
#reagent
<
2018-02-17
>
kurt-o-sys19:02:44

I'm using react-bootstrap-table and I'd like to translate this:

<BootstrapTable data={ jobs }>
          <TableHeaderColumn dataField='id' isKey>Job ID</TableHeaderColumn>
          <TableHeaderColumn dataField='name'>Job Name</TableHeaderColumn>
          <TableHeaderColumn dataField='active' dataFormat={ activeFormatter }>Active</TableHeaderColumn>
      </BootstrapTable>
from: https://allenfang.github.io/react-bootstrap-table/example.html#column-format into cljs. I'm getting as far as:
[:> js/BootstrapTable {:data jobs}
    [:> js/TableHeaderColumn {:dataField "id" :isKey true} Job ID]
    [:> js/TableHeaderColumn {:dataField "name"} Job Name]
    [:> js/TableHeaderColumn {:dataField "active" :dataFormat ???} Active]
  ]
I can't seem to get that function right.

kurt-o-sys19:02:17

if I use a plain function, it renders the result of that function as a string

kurt-o-sys19:02:28

if I do:

(defn activeFormatter [cell]
  (reagent.core/reactify-component [active-format cell]))
this is the result:
function (props, context, updater) { // This constructor gets overridden by mocks. The argument is used // by mocks to assert on what gets mounted. if ("development" !== 'production') { "development" !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See:  : void 0; } // Wire up auto-binding if (this.__reactAutoBindPairs.length) { bindAutoBindMethods(this); } this.props = props; this.context = context; this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; this.state = null; // ReactClasses doesn't have constructors. Instead, they use the // getInitialState and componentWillMount methods for initialization. var initialState = this.getInitialState ? this.getInitialState() : null; if ("development" !== 'production') { // We allow auto-mocks to proceed as if they're returning null. if (initialState === undefined && this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience. initialState = null; } } _invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent'); this.state = initialState; }
(the function itself stringified)

kurt-o-sys19:02:48

what am I missing?

kurt-o-sys19:02:25

ok, got it... I need reagent.core/as-element, not reagent.core/reactify-component 😛