Skip to content

Instantly share code, notes, and snippets.

@stevoland
Created June 18, 2014 17:51
Show Gist options
  • Save stevoland/77697cc77fb457c4f509 to your computer and use it in GitHub Desktop.
Save stevoland/77697cc77fb457c4f509 to your computer and use it in GitHub Desktop.
/** @jsx React.DOM */
var PanelGroup = ReactBootstrap.PanelGroup;
var Panel = ReactBootstrap.Panel;
var mountNode = document.body;
var renderedInstance;
var PanelGroups = React.createClass({
render: function() {
return (
<PanelGroup activeKey={this.props.activeKey} onSelect={this.props.onSelect} isAccordion>
<Panel header="Title 1" key={1}>
<p>Content 1</p>
</Panel>
<Panel header="Title 2" key={2}>
<p>Content 2</p>
</Panel>
</PanelGroup>
);
}
});
var Contract = React.createClass({
getInitialState: function () {
activeKey: 1
},
handleSelect: function (selectedKey) {
this.setState({
activeKey: selectedKey
});
},
render: function() {
return (
<div>
<p>Custom stuff</p>
<PanelGroups activeKey={this.state.activeKey} onSelect={this.handleSelect} />
</div>
);
}
});
renderedInstance = React.renderComponent(<Contract />, mountNode);
@davidbgk
Copy link

It worked with:

  getInitialState: function () {
    return {
      activeKey: 1
    }
  },

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment