|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import ReactDOM from 'react-dom'; |
| 3 | + |
| 4 | +// Importing the Bootstrap CSS |
| 5 | +import 'bootstrap/dist/css/bootstrap.min.css'; |
| 6 | + |
| 7 | +import Toast from 'react-bootstrap/Toast'; |
| 8 | +import Container from 'react-bootstrap/Container'; |
| 9 | +import Button from 'react-bootstrap/Button'; |
| 10 | + |
| 11 | +const ExampleToast: React.FunctionComponent = ({ children }) => { |
| 12 | + const [show, toggleShow] = useState(true); |
| 13 | + |
| 14 | + return ( |
| 15 | + <> |
| 16 | + {!show && <Button onClick={() => toggleShow(true)}>Show Toast</Button>} |
| 17 | + <Toast show={show} onClose={() => toggleShow(false)}> |
| 18 | + <Toast.Header> |
| 19 | + <strong className="mr-auto">React-Bootstrap</strong> |
| 20 | + </Toast.Header> |
| 21 | + <Toast.Body>{children}</Toast.Body> |
| 22 | + </Toast> |
| 23 | + </> |
| 24 | + ); |
| 25 | +}; |
| 26 | + |
| 27 | +const App = () => ( |
| 28 | + <Container className="p-3"> |
| 29 | + <Container className="p-5 mb-4 bg-light rounded-3"> |
| 30 | + <h1 className="header">Welcome To React-Bootstrap</h1> |
| 31 | + <ExampleToast> |
| 32 | + We now have Toasts |
| 33 | + <span role="img" aria-label="tada"> |
| 34 | + 🎉 |
| 35 | + </span> |
| 36 | + </ExampleToast> |
| 37 | + </Container> |
| 38 | + </Container> |
| 39 | +); |
| 40 | + |
| 41 | +const mountNode = document.getElementById('root'); |
| 42 | +ReactDOM.render(<App />, mountNode); |
0 commit comments