I'm new here in reactjs, i'm using react-bootstrap for my UI. Now, I encounter a script where in a setState is the value of a variable and pass it on the onHide of the modal. Im not sure what to search to find an answer that's why I posted a question here.
let closeBoardAddModal = () => this.setState({ boardAddModalShow: false })
<BoardAddModal show={this.state.boardAddModalShow} onHide={closeBoardAddModal} />
In the above stament
closeBoardModalis not a value but is afunction. This the ES6 syntax where()will contain the arguments and anything after=>will be the body of the function. This syntax also the binding operation for you.The above syntax is equivalent to
So in the below code
when you do
onHide={closeBoardAddModal}it will call thefunction closeBoardAddModalon anonHideevent which internally the sets the stateboardAddModalShowtofalse.