According to the Bootstrap website, modals are typically triggered using buttons.
As I am working with React, I would like to control when the modal is displayed using JavaScript.
Is there a way to have the modal appear by default?
Here is the code snippet for Modal.js:
...
return(
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Modal body text goes here.</p>
</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>
)
import "./styles.css";
import Modal from './Model'
export default function App() {
return (
<div className="App">
<h1>123</h1>
<Modal/>
</div>
);
}