Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.

Commit 6b4f2eb

Browse files
author
jung-han
committed
feat: add reactive options
1 parent 267cf7e commit 6b4f2eb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const reactivePropSetterMap = {
55
data: 'resetData',
66
columns: 'setColumns',
77
bodyHeight: 'setBodyHeight',
8-
frozenColumnCount: 'setFrozenColumnCount'
8+
frozenColumnCount: 'setFrozenColumnCount',
9+
columnOptions: 'setFrozenColumnCount'
910
};
1011

1112
export default class Grid extends React.Component {
@@ -50,8 +51,15 @@ export default class Grid extends React.Component {
5051
);
5152

5253
reactiveProps.forEach((propName) => {
53-
const currentValue = this.props[propName];
54-
const nextValue = nextProps[propName];
54+
let currentValue, nextValue;
55+
if (propName === 'columnOptions' && this.props.columnOptions) {
56+
currentValue = this.props.columnOptions.frozenCount;
57+
nextValue = nextProps.columnOptions.frozenCount;
58+
} else {
59+
currentValue = this.props[propName];
60+
nextValue = nextProps[propName];
61+
}
62+
5563
if (currentValue !== nextValue) {
5664
const setterName = reactivePropSetterMap[propName];
5765
this.gridInst[setterName](nextValue);

stories/index.stories.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ stories.add('Events', () => {
120120
stories.add('Reactive Props', () => {
121121
const dataValue = object('data', data.slice(0, 5));
122122
const columnsValue = object('columns', columns);
123+
const columnOptions = object('columnOptions', {frozenCount: 2});
123124
const bodyHeightValue = number('bodyHeight', 300, {
124125
range: true,
125126
min: 100,
@@ -137,6 +138,7 @@ stories.add('Reactive Props', () => {
137138
columns={columnsValue}
138139
data={dataValue}
139140
frozenColumnCount={frozenColumnCountValue}
141+
columnOptions={columnOptions}
140142
pagination={false}
141143
bodyHeight={bodyHeightValue}
142144
oneTimeBindingProps={oneTimeBindingProps}

0 commit comments

Comments
 (0)