reactjsbootstrap-modalinternet-explorer-10react-bootstrap

React: React-bootstrap modal not working in ie 10


Using React-Bootstrap, I have a modal that conditionally opens. The modal works fine in ie 11.

Here is the modal that works in ie11..

handleCloseAlert() {
  this.setState({ alertShow: false });
}

handleShowAlert() {
  this.setState({ alertShow: true });
}
noResults() {
  this.setState({alertShow:true})
}

<Modal show={this.state.alertShow} 
          onHide={this.handleCloseAlert}
          {...this.props}
          data-toggle="modal"
          size="sm"
          aria-labelledby="contained-modal-title-vcenter"
          centered>
          <Modal.Header closeButton>
            <Modal.Body>No results found</Modal.Body>
          </Modal.Header>
        </Modal>

When I test in ie10 the screen goes white when the modal is supposed to open. Here is the error I get in console..

[object Error]{description: "Unable to s...", message: "Unable to s...", name: "TypeError", number: -2146823281, stack:
Unhandled promise rejection TypeError: Unable to set property 'paddingRight' of undefined or null reference

I also tested using just Bootstrap code and the modal works with the example code from bootstrap's website. I suppose I could use their code, but I couldnt firgure out how to conditionally open and close the modal.

Here is the example from bootstrap that is not coded for conditional react rendering..

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

I tried adding show={this.state.alertShow} to the modal tag, but I get this error in the console.

Warning: Received `false` for a non-boolean attribute `show`.

If you want to write it to the DOM, pass a string instead: show="false" or show={value.toString()}.

If you used to conditionally omit it with show={condition && value}, pass show={condition ? value : undefined} instead.

Is there a way to keep my current code and get it to work with ie10? Or do I need to recode without React-Bootstrap?

I also have import 'react-app-polyfill/ie9'; in my index.js


Solution

  • Modal is working with the new react-bootstrap update