Allow null TableRow sidebars

Summary: Makes the API a bit easier to use. Don't have to build an empty sidebar if you don't want one.

Reviewed By: passy

Differential Revision: D15064205

fbshipit-source-id: bd31c1aa97fd6d1c93717c10b268f49e44eb1299
This commit is contained in:
John Knox
2019-04-26 09:24:20 -07:00
committed by Facebook Github Bot
parent 4049720759
commit f00ff72211
2 changed files with 2 additions and 2 deletions

View File

@@ -92,7 +92,7 @@ public abstract class TableRow {
columnsObject.put("id", id);
return new FlipperObject.Builder()
.put("columns", columnsObject.build())
.put("sidebar", sidebar.serialize())
.put("sidebar", sidebar != null ? sidebar.serialize() : null)
.put("id", id)
.build();
}

View File

@@ -199,7 +199,7 @@ function renderToolbar(section: ToolbarSection) {
function renderSidebarForRow(rowData: RowData): Node {
if (!rowData.sidebar) {
throw new Error('renderSidebar used with missing rowData.sidebar');
return null;
}
if (!Array.isArray(rowData.sidebar)) {
throw new Error('typeof rowData.sidebar is not array as expected: ');