GithubHelp home page GithubHelp logo

Comments (5)

hipstersmoothie avatar hipstersmoothie commented on July 21, 2024 1

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.

@zenflow

from sweetalert2-react.

hipstersmoothie avatar hipstersmoothie commented on July 21, 2024

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.

zenflow avatar zenflow commented on July 21, 2024

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.

illtrax avatar illtrax commented on July 21, 2024

@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.

alex-shamshurin avatar alex-shamshurin commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.