Last active
June 9, 2017 02:11
-
-
Save arackaf/efcc6544dcb8b00b8816801e637cf0a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Children, Component, cloneElement} from 'react'; | |
| import Collapse from 'react-collapse'; | |
| export default class RunAccordion extends Component { | |
| state = {xShown: false, yShown: false}; | |
| addX = () => this.setState({xShown: true}); | |
| addY = () => this.setState({yShown: true}); | |
| removeX = () => this.setState({xShown: false}); | |
| removeY = () => this.setState({yShown: false}); | |
| render(){ | |
| return ( | |
| <div style={{margin: '70px'}}> | |
| <button onClick={this.addX}>Add X</button> | |
| <button onClick={this.addY}>Add Y</button> | |
| <button onClick={this.removeX}>Remove X</button> | |
| <button onClick={this.removeY}>Remove Y</button> | |
| <br /> | |
| <Accordion> | |
| <AccordionItem name="a" caption="Pane A"> | |
| <h3>This is pane a</h3> | |
| </AccordionItem> | |
| <AccordionItem defaultOpen={true} name="b" caption="Pane B"> | |
| <h3>This is pane b</h3> | |
| </AccordionItem> | |
| <AccordionItem name="c" caption="Pane C"> | |
| <h3>This is pane c</h3> | |
| </AccordionItem> | |
| {this.state.xShown ? | |
| <AccordionItem defaultOpen={true} name="x" caption="Pane X"> | |
| <h3>This is pane x</h3> | |
| </AccordionItem> : null | |
| } | |
| {this.state.yShown ? | |
| <AccordionItem name="y" caption="Pane Y"> | |
| <h3>This is pane y</h3> | |
| </AccordionItem> : null | |
| } | |
| </Accordion> | |
| </div> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment