<div id="app"></div>
console.clear();
const MyComponent1 = (props) => {
  return (
    <div>
    <div className="modal" style={{ display: 'block' }} tabIndex="-1">
      <div className="modal-dialog">
        <div className="modal-content">
          <div className="modal-header">
            <h5 className="modal-title">Modal title</h5>
            <button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div className="modal-body">
            <p>Modal body text goes here.</p>
          </div>
          <div className="modal-footer">
            { props.children }
          </div>
        </div>
      </div>
    </div>
      </div>
  )
}

const App = () => {
  return (
    <div>
      <MyComponent1>
         <button type="button" className="btn btn-secondary" data-bs-dismiss="modal">關閉</button>
         <button type="button" className="btn btn-primary">儲存</button>
      </MyComponent1>
    </div>
  )
}

const app = document.querySelector('#app');
const root = ReactDOM.createRoot(app);
root.render(<App />);
View Compiled

External CSS

  1. https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css

External JavaScript

  1. https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js
  2. https://unpkg.com/react@18/umd/react.development.js
  3. https://unpkg.com/react-dom@18/umd/react-dom.development.js