TypeError: r.render is not a function when attempting to use standalone version
productiveme opened this issue · comments
When including react-pivot-standalone-1.18.1.min.js on the page and calling the following code:
var rows = [
{"firstName":"Francisco","lastName":"Brekke","state":"NY","transaction":{"amount":"399.73","date":"2012-02-02T08:00:00.000Z","business":"Kozey-Moore","name":"Checking Account 2297","type":"deposit","account":"82741327"}},
{"firstName":"Francisco","lastName":"Brekke","state":"NY","transaction":{"amount":"768.84","date":"2012-02-02T08:00:00.000Z","business":"Herman-Langworth","name":"Money Market Account 9344","type":"deposit","account":"95753704"}}
];
var dimensions = [
{value: 'firstName', title: 'First Name'}
];
var reduce = function(row, memo) {
memo.amountTotal = (memo.amountTotal || 0) + parseFloat(row.transaction.amount)
return memo
};
var calculations = [
{
title: 'Amount', value: 'amountTotal',
template: function(val, row) {
return '$' + val.toFixed(2)
}
}
];
ReactPivot($('#pivot')[0], {
rows: rows,
dimensions: dimensions,
calculations: calculations,
reduce: reduce
});
I get an exception TypeError: r.render is not a function at e.exports
Can anyone please help me to get this module working without browserify and react in my project?
In the end I got it working by cloning the project, running
npm install
npm un --save react react-dom
npm i --save react@0.12.2
npm run dist
If I use the dist/react-pivot-standalone-1.18.1.min.js
file in an empty project, I can get it to render. It seems the issue is with the version of react installed when building this dist.
I fixed for newer React versions by modifying "load.js" to use ReactDom...