title: how close parent modal when open child modal in Reactjs?
body: <p>I can not close current modal when open new modal in React js. please help me.
  I have parent modal: Register_modal  and child of it: RegisterCode_Modal
  parent modal is called in header component:</p>
  
  <p><strong><em>first: Header component</em></strong></p>
  
  <p>this component call first modal and pass open and close props to it:</p>
  
  <pre><code>import React , {Component} from 'react';
  import ReactDOM from 'react-dom';
  import {NavLink} from 'react-router-dom';
  import Register_Modal from './Register_Modal';
  
  
  export default class Header extends Component {
      constructor() {
          super();
  
          this.state = {
           modalIsOpen: false
          };
      this.openModal = this.openModal.bind(this);
      this.closeModal = this.closeModal.bind(this);
      }
  
      openModal(e) {
          e.preventDefault();
          this.setState({modalIsOpen: true});
        }
  
      closeModal(e) {
          e.preventDefault();
          this.setState({modalIsOpen: false});
        }
  
    render() {
      return (
  &lt;div&gt;
  &lt;div className="button navbar-right"&gt;
     &lt;button className="navbar-btn nav-button wow bounceInRight login"  data-wow-delay="0.45s"&gt;ورود&lt;/button&gt;
     &lt;button className="navbar-btn nav-button wow fadeInRight"  data-wow-delay="0.48s" onClick={this.openModal} &gt;ثبت نام&lt;/button&gt;
                          &lt;div &gt;
   &lt;Register_Modal open={this.state.modalIsOpen} close={this.closeModal} /&gt;
                          &lt;/div&gt;
  
  &lt;/div&gt;
      );
    }
  
  
  }
  ---------------------------------------------------------------------------
  </code></pre>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <h2><strong><em>second: parent component</em></strong></h2>
  
  <pre><code>export default class Register_Modal extends Component {
     constructor(props){
         super(props);
         this.state={
             codemodal: false
         };
         this.openCodeModal=this.openCodeModal.bind(this);
         this.closeCodeModal=this.closeCodeModal.bind(this);
     }
     openCodeModal(e){
         e.preventDefault();
         this.setState({codemodal: true});
     }
     closeCodeModal(e){
      e.preventDefault();
      this.setState({codemodal: false});
  }
      render() {
        return (
          &lt;div&gt;  
                &lt;Modal  
                isOpen={this.props.open} 
                onRequestClose={this.props.close}
                ariaHideApp={false}
                contentLabel="selected option"
                isClose={this.props.close}
                style={customStyles}
                &gt;
                &lt;h2&gt;salammmmm&lt;/h2&gt;
                &lt;button onClick={this.props.close} &gt;انصراف&lt;/button&gt;
                &lt;button onClick={this.openCodeModal} &gt;بعدی&lt;/button&gt;
  
                &lt;/Modal&gt;
                &lt;div className="ReactModalPortal"&gt;
                &lt;RegisterCode_Modal open={this.state.codemodal} close={this.closeCodeModal}  /&gt;
                &lt;/div&gt;
                {this.props.close}
            &lt;/div&gt;
  
        );}
      }
  ------------------------------------------------------------------
  </code></pre>
  
  <h2><strong><em>third: child component</em></strong></h2>
  
  <pre><code>export default class RegisterCode_Modal extends Component {
      constructor(props){
          super(props);
          console.log("injaaaaa");
      }
  
  
   render() {
     return (
       &lt;div&gt;  
             &lt;Modal  
             isOpen={this.props.open} 
             onRequestClose={this.props.close}
             ariaHideApp={false}
             contentLabel="ورود کد"
             isClose={this.props.close}
             style={customStyles}
             &gt;
             &lt;h2&gt;مرحله کد&lt;/h2&gt;
             &lt;button onClick={this.props.close} &gt;تائید&lt;/button&gt;
             &lt;/Modal&gt;
         &lt;/div&gt;
  
     );}
   }
  </code></pre>