Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kossel/collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
kossel committed Apr 2, 2018
2 parents 657c991 + a31144c commit 7fbf41e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
24 changes: 8 additions & 16 deletions examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ function random() {
}

class Test extends React.Component {
constructor(props) {
super(props);
this.state = this.getInitialState();
['onChange', 'setActivityKey', 'reRender', 'toggle'].map(fn => this[fn] = this[fn].bind(this));
state = {
time: random(),
accordion: false,
activeKey: ['4'],
}

getInitialState() {
return {
time: random(),
accordion: false,
activeKey: ['4'],
};
}

onChange(activeKey) {
onChange = (activeKey) => {
this.setState({
activeKey,
});
Expand Down Expand Up @@ -71,19 +63,19 @@ class Test extends React.Component {
return items;
}

setActivityKey() {
setActivityKey = () => {
this.setState({
activeKey: ['2'],
});
}

reRender() {
reRender = () => {
this.setState({
time: random(),
});
}

toggle() {
toggle = () => {
this.setState({
accordion: !this.state.accordion,
});
Expand Down
10 changes: 2 additions & 8 deletions src/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ import PanelContent from './PanelContent';
import Animate from 'rc-animate';

class CollapsePanel extends Component {
constructor(props) {
super(props);
this.handleItemClick = this.handleItemClick.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
}

handleItemClick() {
handleItemClick = () => {
if (this.props.onItemClick) {
this.props.onItemClick();
}
}

handleKeyPress(e) {
handleKeyPress = (e) => {
e.preventDefault();
if (e.charCode === 13 || e.charCode === 32) {
this.handleItemClick();
Expand Down

0 comments on commit 7fbf41e

Please sign in to comment.