Comments (5)
I'd expect most everything that is related to the dom to be expressed through jsx.
If another developer were to come into my project with SweetAlert as just a function, it might be confusing finding the one place in my app where dom isn't expressed through jsx in a render function. Since this repo makes it a component I can keep all my jsx inside my render function and the outside developer wouldn't have to learn about a new api that defines jsx in an onclick callback. They would just look to the render function and see that the component can render a modal.
from sweetalert2-react.
To me it makes sense even though there might be a little overhead. As a react developer i like things being components and having a little thought about being in React.
I agree with you that the swal component should probably not be in the dom all the time. We might want to take the same approach that the Material-UI modals do (they aren't rendered to the dom unless shown. Demo and source here:
https://material-ui-next.com/api/modal/
I think we should move to an even more react-y state and do something like:
<div>
<Typography gutterBottom>Click to get the full Modal experience!</Typography>
<Button onClick={this.handleOpen}>Open Modal</Button>
<SweetAlert
open={this.state.open}
onClose={this.handleClose}
>
<div className={classes.paper}>
<h2>
Text in a modal
</h2>
<p id="simple-modal-description">
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
</p>
</div>
</SweetAlert>
</div>
(opened issue #9)
The one thing that doesn't make sense to when Swal is a component is the then. I haven't played around with trying to chain the Swal Components but I don't see how it would work out in my head.
from sweetalert2-react.
To me it makes sense even though there might be a little overhead. As a react developer i like things being components and having a little thought about being in React.
@hipstersmoothie But why does everything need to be a React component? If not using a component results in simpler, more concise code, then isn't that better?
from sweetalert2-react.
@zenflow - If you want reusable code, then you want everything to be a component. If it's a small project that doesn't need to scale, then by all means, go for simple.
from sweetalert2-react.
The answer is - yes, this is a component. After all, it will be replaced with sweetalert in react version.
from sweetalert2-react.
Related Issues (20)
- Mistakes in README HOT 4
- How to use preConfirm? HOT 2
- customize font family
- Footer HOT 3
- Input type not working HOT 3
- Html content warning Invalid prop HOT 8
- Add support for more configurations HOT 2
- onCancel not called HOT 14
- confirmButtonClass deprecated
- Lost the ability to render components
- Quick fix please: Typo give bug HOT 11
- Critical error on call method onCancel HOT 13
- type="input" not working HOT 5
- Modal disappears ... HOT 1
- window is not defined in nextjs HOT 2
- Build is failing
- Any plans to support new version of SweetAlert2?
- Examples
- Enable React children to be used as html on the sweetalert component HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sweetalert2-react.