diff --git a/packages/react-bootstrap-table2/src/contexts/index.js b/packages/react-bootstrap-table2/src/contexts/index.js
index 3d6e644..e695480 100644
--- a/packages/react-bootstrap-table2/src/contexts/index.js
+++ b/packages/react-bootstrap-table2/src/contexts/index.js
@@ -8,49 +8,37 @@ import createSelectionContext from './selection-context';
import remoteResolver from '../props-resolver/remote-resolver';
import dataOperator from '../store/operators';
-const withContext = (Base) => {
- let DataContext;
- let SelectionContext;
- let CellEditContext;
- let SortContext;
- let FilterContext;
- let PaginationContext;
-
- return class BootstrapTableContainer extends remoteResolver(Component) {
+const withContext = Base =>
+ class BootstrapTableContainer extends remoteResolver(Component) {
constructor(props) {
super(props);
- DataContext = createDataContext(props.data);
+ this.DataContext = createDataContext(props.data);
if (props.columns.filter(col => col.sort).length > 0) {
- SortContext = createSortContext(dataOperator, this.isRemoteSort, this.handleSortChange);
+ this.SortContext = createSortContext(
+ dataOperator, this.isRemoteSort, this.handleSortChange);
}
if (props.selectRow) {
- SelectionContext = createSelectionContext(dataOperator);
+ this.SelectionContext = createSelectionContext(dataOperator);
}
if (props.cellEdit && props.cellEdit.createContext) {
- CellEditContext = props.cellEdit.createContext(
+ this.CellEditContext = props.cellEdit.createContext(
_, dataOperator, this.isRemoteCellEdit, this.handleCellChange);
}
if (props.filter) {
- FilterContext = props.filter.createContext(
+ this.FilterContext = props.filter.createContext(
_, this.isRemoteFiltering, this.handleRemoteFilterChange);
}
if (props.pagination) {
- PaginationContext = props.pagination.createContext(
+ this.PaginationContext = props.pagination.createContext(
this.isRemotePagination, this.handleRemotePageChange);
}
}
- componentWillReceiveProps(nextProps) {
- if (!nextProps.cellEdit) {
- CellEditContext = null;
- }
- }
-
renderBase() {
return (
rootProps,
@@ -80,12 +68,12 @@ const withContext = (Base) => {
sortProps,
paginationProps
) => (
-
-
+
{
selectionProps => base(
rootProps,
@@ -96,8 +84,8 @@ const withContext = (Base) => {
selectionProps
)
}
-
-
+
+
);
}
@@ -108,12 +96,12 @@ const withContext = (Base) => {
filterProps,
sortProps
) => (
- this.paginationContext = n }
pagination={ this.props.pagination }
data={ rootProps.getData(filterProps, sortProps) }
>
-
+
{
paginationProps => base(
rootProps,
@@ -123,8 +111,8 @@ const withContext = (Base) => {
paginationProps
)
}
-
-
+
+
);
}
@@ -134,14 +122,14 @@ const withContext = (Base) => {
cellEditProps,
filterProps
) => (
- this.sortContext = n }
defaultSorted={ this.props.defaultSorted }
defaultSortDirection={ this.props.defaultSortDirection }
data={ rootProps.getData(filterProps) }
>
-
+
{
sortProps => base(
rootProps,
@@ -150,8 +138,8 @@ const withContext = (Base) => {
sortProps
)
}
-
-
+
+
);
}
@@ -160,12 +148,12 @@ const withContext = (Base) => {
rootProps,
cellEditprops
) => (
- this.filterContext = n }
data={ rootProps.getData() }
>
-
+
{
filterProps => base(
rootProps,
@@ -173,24 +161,24 @@ const withContext = (Base) => {
filterProps
)
}
-
-
+
+
);
}
renderWithCellEditCtx(base, baseProps) {
return rootProps => (
-
-
+
{
cellEditprops => base(rootProps, cellEditprops)
}
-
-
+
+
);
}
@@ -200,40 +188,39 @@ const withContext = (Base) => {
let base = this.renderBase();
- if (SelectionContext) {
+ if (this.SelectionContext) {
base = this.renderWithSelectionCtx(base, baseProps);
}
- if (PaginationContext) {
+ if (this.PaginationContext) {
base = this.renderWithPaginationCtx(base, baseProps);
}
- if (SortContext) {
+ if (this.SortContext) {
base = this.renderWithSortCtx(base, baseProps);
}
- if (FilterContext) {
+ if (this.FilterContext) {
base = this.renderWithFilterCtx(base, baseProps);
}
- if (CellEditContext) {
+ if (this.CellEditContext) {
base = this.renderWithCellEditCtx(base, baseProps);
}
return (
-
-
+
{
base
}
-
-
+
+
);
}
};
-};
export default withContext;