Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap collapse with react js

Tags:

Hi I'm trying to use bootstrap collapse inside a react view and it's not working. It's very simple but I don't understand what's going on.

return (<div>
    <button className="btn" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="true" aria-controls="collapseExample">
        ButtonClickthis!
    </button>
    <div className="collapse" id="collapseExample">
        <div className="well">
            ...blablablacontent
        </div>
    </div>
</div>);
like image 789
François Richard Avatar asked Jan 07 '15 13:01

François Richard


1 Answers

Bootstrap will not work out of the box for react components, since it parses the DOM on load and attaches event listeners etc. You can try something like react-bootstrap or manually triggering inside the componentDidMount lifecycle.

– David

like image 188
2 revs Avatar answered Oct 23 '22 13:10

2 revs