2015-10-25 89 views
1

我遇到了折叠问题。点击处理程序正在工作,但额外区域仅在下一次重新写入父组件后才会(未)折叠。这两种方式React-Bootstrap折叠按钮不起作用

  • 坏消息出现在点击时没有动画
  • 一个子组件越来越重画时,有由父母为其道具没有变化(因为你可以看到extra值这个班是私人的)。

搜索后,我以前找不到这个问题。我如何得到崩溃以配合按钮点击。

import { Grid, Row, Col, Input, Button, Collapse } from 'react-bootstrap';

import styles from './styles'; 

export class Entry extends Component { 

    constructor(props) { 
    super(props); 
    this.extra = false; // alternative that also did not work 
    this.settings = {extra:false}; 
    } 

    render() { 
    const { entryData } = this.props; 

    return (
     <div className={styles}> 
     <h3 className="orgname">{entryData.orgName}</h3> 
     <Button bsSize="xsmall" onClick={this.close}>X</Button> 

     <Button onClick={() => {this.settings.extra = !this.settings.extra; console.log("click", this.settings.extra) } } > 
      more... 
     </Button> 
     <Collapse in={this.settings.extra}> 
      <div> 
       Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 
       Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. 
      </div> 
     </Collapse> 

     </div> 
    ); 
    } 
} 
+0

我遇到了这个问题。我发现我必须在Collapse inline中定义所有组件。换句话说,当我在其他地方定义的Collapse中使用了我自己的组件时,它失败了。不知道为什么。 – landerton

回答