React-bootstrap-table2: Cannot read property 'get' of null

Created on 14 Apr 2020  路  7Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

Reopening bug #459. Bug still exists:

Using the following versions:
"react-bootstrap-table-next": "^3.3.1",
"react-bootstrap-table2-editor": "^1.4.0",
"react-bootstrap-table2-paginator": "^2.0.7",
"react-bootstrap-table2-toolkit": "^2.1.2",

Code:
keyField="uuid"
data={ this.state.students }
columns={ Columns }
exportCSV
exportAll="false"
>
{
props => (





keyField="uuid"
data={this.state.students}
columns={Columns}
bordered={false}
striped
hover
noDataIndication="Table is Empty"
pagination={paginationFactory(options)}
bootstrap4
/>

)
}

Pressing "Export to CSV" button returns following console error:

Uncaught TypeError: Cannot read property 'get' of null
at :3000/static/js/0.chunk.js:168336
at Array.map ()
at :3000/static/js/0.chunk.js:168335
at Array.map ()
at transform (:3000/static/js/0.chunk.js:168334)
at CSVOperation._this.handleExportCSV (:3000/static/js/0.chunk.js:168538)
at onClick (:3000/static/js/0.chunk.js:168250)
at HTMLUnknownElement.callCallback (:3000/static/js/0.chunk.js:185718)
at Object.invokeGuardedCallbackDev (:3000/static/js/0.chunk.js:185767)
at invokeGuardedCallback (:3000/static/js/0.chunk.js:185820)
at invokeGuardedCallbackAndCatchFirstError (:3000/static/js/0.chunk.js:185835)
at executeDispatch (:3000/static/js/0.chunk.js:185920)
at executeDispatchesInOrder (:3000/static/js/0.chunk.js:185945)
at executeDispatchesAndRelease (:3000/static/js/0.chunk.js:188829)
at executeDispatchesAndReleaseTopLevel (:3000/static/js/0.chunk.js:188838)
at forEachAccumulated (:3000/static/js/0.chunk.js:188810)
at runEventsInBatch (:3000/static/js/0.chunk.js:188855)
at runExtractedPluginEventsInBatch (:3000/static/js/0.chunk.js:189065)
at handleTopLevel (:3000/static/js/0.chunk.js:189109)
at batchedEventUpdates$1 (:3000/static/js/0.chunk.js:207255)
at batchedEventUpdates (:3000/static/js/0.chunk.js:186327)
at dispatchEventForLegacyPluginEventSystem (:3000/static/js/0.chunk.js:189119)
at attemptToDispatchEvent (:3000/static/js/0.chunk.js:189839)
at dispatchEvent (:3000/static/js/0.chunk.js:189760)
at unstable_runWithPriority (:3000/static/js/0.chunk.js:211416)
at runWithPriority$1 (:3000/static/js/0.chunk.js:196605)
at discreteUpdates$1 (:3000/static/js/0.chunk.js:207272)
at discreteUpdates (:3000/static/js/0.chunk.js:186340)
at dispatchDiscreteEvent (:3000/static/js/0.chunk.js:189739)

Most helpful comment

Changing line 44 of +react-bootstrap-table2-toolkit\lib\src\csv\exporter.js from:
var cellContent = _.get(row, m.field);
to
var cellContent = row[m.field];

corrects issue.

All 7 comments

Changing line 44 of +react-bootstrap-table2-toolkit\lib\src\csv\exporter.js from:
var cellContent = _.get(row, m.field);
to
var cellContent = row[m.field];

corrects issue.

your example is broken. please create a simple and minimal example on codesandbox so that I can help u efficiently. thanks

Hi,
Here is a codesandbox showing the issue with react-bootstrap-table2-toolkit-2.1.3,
https://codesandbox.io/s/agitated-shaw-5t0jj
And the fix suggested by _ahiltgen_ works. I manually changed the code in /node_modules/react-bootstrap-table2-toolkit/dist/react-bootstrap-table2-toolkit.js, and npm start, then it works correctly on clicking the export csv button.

Why is this issue closed? It has not been fixed.

Hi,
Here is a codesandbox showing the issue with react-bootstrap-table2-toolkit-2.1.3,
https://codesandbox.io/s/agitated-shaw-5t0jj
And the fix suggested by _ahiltgen_ works. I manually changed the code in /node_modules/react-bootstrap-table2-toolkit/dist/react-bootstrap-table2-toolkit.js, and npm start, then it works correctly on clicking the export csv button.

Thank you for posting the codesandbox example.

Changing line 44 of +react-bootstrap-table2-toolkit\lib\src\csv\exporter.js from:
var cellContent = _.get(row, m.field);
to
var cellContent = row[m.field];

corrects issue.

Hi ahiltgen,

It resolve the issue but upon exporting hidden columns are included in exported csv file. Is there any posible way to handle also the hidden columns not to be included.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

primakashi picture primakashi  路  3Comments

bogannathan picture bogannathan  路  4Comments

eylonronen picture eylonronen  路  3Comments

SandeepKapalawai picture SandeepKapalawai  路  3Comments

prajapati-parth picture prajapati-parth  路  4Comments