Added customBodyRenderLite / removed object deprecation for column values #1339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
customBodyRenderLite
customBodyRenderLite is a way of rendering data in a more performant way. Using it can lead to tables that render quicker. Before going further, here is a brief technical description of how customBodyRender works under the covers:
If the data changes, both of the above happen again. This means if you have a table of 1000 rows and 10 columns (all with customBodyRender), A total of 1000 * 10 * 2 = 20,000 function calls get executed related to rendering.
Unlike customBodyRender, the value returned from customBodyRenderLite is not used for filtering. So it's return value has no affect on filters. Instead, filters use the value in the data array. Additionally, unlike customBodyRender, customBodyRenderLite is only called for cells that are visible on the current page. This means for the same table, if you have 10 rows per page, a total of 10 * 10 = 100 function calls get made. A test showing this dynamic has been added.
Another trade off for customBodyRenderLite is that it doesn't take in
(value, tableMeta, update)
, instead it simply takes in(dataIndex, rowIndex)
. This means you have to lookup a value yourself (though personally I've found having the dataIndex is much more useful).Objects no longer deprecated
Back in release 2.12.2, a deprecation warning was added stating that objects would no longer be accepted as values for data (with the exception of arrays). This occurred because of this issue: #915. Essentially what was happening was the filter dialog would cause the table to blow up when given object data.
Forbidding objects is overkill though, as being able to input them is extremely useful. I've patched the error that occurred for the filter dialog. There are two basic problems that remain: